HOW TO HOST MUTIPLE WEBPAGES USING THE ESP8266 AS SERVER USING THE ARDUINO IDE?
by lolipop8867 in Circuits > Microcontrollers
749 Views, 4 Favorites, 0 Comments
HOW TO HOST MUTIPLE WEBPAGES USING THE ESP8266 AS SERVER USING THE ARDUINO IDE?

- It is possible to host multiple pages by using the very power full ESP8266.
- We will be using the RESTful web services for our purpose.
- We will be using the Arduino environment for building the code.
INTRODUCTION

Before doing this project having a prior knowledge of the following things is necessary
- How to make a web server with the ESP-8266.
- Basic concepts of the RESTful web services.
- What is a station and what is an access point.
NOTE: We will be using the HTTP GET requests for this project
Starting the Web Server

Start the server on the ESP-8266 and start listing to the clients from the port 80.
NOTE: The server can be either a soft-AP server or the normal station server. This project can be configured to work in both the configuration.
Check If the Client Is Connected or Not
.png)
.png)
- Once the code is uploaded, then check for the WiFi Access point by the name SSID and type the password.
- Once you have successfully connected to the network, open your Web browser which in this case is the client, and type the IP address as shown.
-
If the ESP8266 is configured as the Station server, then use the WiFi.localIP() function to know the ip address.
-
If the ESP8266 is configured as the soft-AP server, then by default 192.168.4.1 will the IP address.This IP address will be used to access the server.
NOTE: However in this project we will configure the ESP8266 as the soft-AP server.
Host Your First Web Page
.png)
.png)
Write a simple HTML hello world code as shown.
Managing the GET REQUESTS
.png)
.png)
- As shown in the step 4, to access the webpage, we just type the IP address of the server on the browser. Now lets do something very interesting.
- We are now going to access the various web pages using the GET requests.
- In this example the GET request is of the type : http:/192.168.4.1/first?first&
- If we type the above URI in the browser, then we see a welcome webpage but if we type any other URI it will show a error webpage.
Refer the start_server.ino for the detailed view of the code
Downloads
Final Step: Switching From One Web Page to Another Webpage
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
- To first visit the Login page use the following URI: http:/192.168.4.1/login?
- Then the following URI is used to switch from one page to another: http:/192.168.4.1/page?value=pageNumber&.
Example :
http:/192.168.4.1/page?value=1& will go to the first page
http:/192.168.4.1/page?value=5& will go to the last page
http:/192.168.4.1/page?logout& will display the Thank you page
Refer to the Final_switch_multiple_page.ino for the detailed view of the code:
Downloads
Refers
image source: