Creating multiple webpages on same ethernet server using w5500 and ESP32

I am using W5500 with esp32 to create a webserver. So far, I have:

  • successfully created the webserver on esp

  • Thrown an HTML webpage on the IP, accessed it through my browser

  • Recieved a GET string from the client, and used it according to my requirements.

Now, I want to create multiple pages on the same webserver that can be accessed like this through the browser:

192.168.1.177/settings
192.168.1.177/configurations

something similar to the server.on function in case of a wifi server. Is there something similar in Ethernet.h or Ethernet2.h?
Thanks :slight_smile:

The Ethernet library does just that. You are layers above in application space using HTTP and it’s up to you to parse the incoming GET air POST requests (or others) and answer accordingly

May be the asyncWebServer library can be hacked to use Ethernet instead of WiFi as the underlying transport layer

1 Like

Thanks.
I have parsed the GET/POST as I wanted.
My only issue is that now I need multiple pages that can be accessed through the same IP but with different directory/subdirectory.

well the GET requests should tell you this

for example 192.168.1.177/settings will be a GET for /settings and 192.168.1.177/configurations will be a GET for /configurations

if you can parse the GET you know which page is requested. Then it's a matter of just returning the right content.

char * requestedURI; // extracted from the GET request, will be "/" or  "/settings" or "/configurations"

... // extract URI from GET request

if (strcmp(requestedURI, "/") == 0) {
  // here send the home page
  ...
} 
else  if (strcmp(requestedURI, "/settings") == 0) {
  // here send the settings page
  ...
} 
else if (strcmp(requestedURI, "/configurations") == 0) {
  // here send the configurations page
  ...
} 
else {
  // here send the error HTTP 404, 404 not found error 
  ...
}
1 Like

Thanks, I'll try that. :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.