Page 1 of 1

Access Point - Extract query from URL

Posted: Sat Feb 20, 2021 8:55 pm
by skywest
Hi,

Complete MicroPython newbie here.

I have set up an ESP8266 as access point and defined a simple web page served to any browser connecting to it.
If the browser connects to the access point with a query string attached to the url, e.g 192.168.4.1?var1=10&var2=20 ..... etc., what method would the ESP8266 use to extract these values from the url?

Any pointers appreciated!

Re: Access Point - Extract query from URL

Posted: Fri Feb 26, 2021 1:21 am
by jimmo
skywest wrote:
Sat Feb 20, 2021 8:55 pm
If the browser connects to the access point with a query string attached to the url, e.g 192.168.4.1?var1=10&var2=20 ..... etc., what method would the ESP8266 use to extract these values from the url?
Can you provide more information about how your web server works?

When the browser connects to http://hostname/foo/bar?a=b it will say

GET /foo/bar?a=b HTTP/1.1
Host: hostname

So you can extract the url parameters from the GET line. In Python the easiest way to do this (if your web server library doesn't already do this for you) is using split.