HTTP_GET/HTTP_POST Server.send() results #597
Replies: 1 comment
-
|
Well, I am an idiot. I was getting the server.args AFTER I was redoing a Server.send. I have updated the code above to: // https://techtutorialsx.com/2017/03/26/esp8266-webserver-accessing-the-body-of-a-http-request/ And it now spits out the args to the serial port and to the webpage. Arduino Sketch: https://drive.google.com/file/d/15G4ZsRzyz230ufpJafNP85mVuqBmsCrS/view?usp=sharing Server.on("/wolfGetResult", HTTP_GET, handleWolfGetResult); Also, another issue I was having is that it matters the order of operation of the Server.on functions: Server.on("/wolf", HTTP_ANY, handleWolf); Server.on("/wolf", handleWolf) would always trigger and the HTTP_POST and HTTP_GET variants wouldn't! So, for proper operation: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to switch over some examples to use the AutoConnect Library.
I have a simple form HTML that I would like to do a HTTP_GET or HTTP_POST with and save a form field onto the ESP32 based on a user input. I can use the submit button of the form and the method of POST or GET to call the appropriate Server.on function. However, I am not able to find where the results are returned to parse for either POST or GET methods. It seems logical that these would be available and I must simply be overlooking something:
Arduino Sketch: https://drive.google.com/file/d/15G4ZsRzyz230ufpJafNP85mVuqBmsCrS/view?usp=sharing
I do the following and I can get through to the POST or the GET handlers:
Server.on("/wolf", HTTP_POST, handleWolfPost);
Server.on("/wolf", HTTP_GET, handleWolfGet);
so, handleWolfGet() looks something like:
String page = SOME FORM HTML that does a GET method and an action=/wolf on button submit
Server.send(200, "text/html", page);
I then fill out the form, click submit, and it returns to the GET method and has a /wolf?ssid=text in the URL (note, I just call this ssid as the name, but it is just a place holder, this could very easily be foo or something generic that I want to put into the ESP32 to set a flag or something, I fully realize the AutoConnect handles SSIDs and such).
Once I am in the handler, how do I action on the HTTP response from the GET/POST method?
If I use the AsyncWebServer using other examples and not the AutoConnect library I run AsyncWebServerRequest
Server.on("/wolf", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html, processor);
});
Then I can do operations on the request like:
request->getParam("ssid")->value();
I can then use this to write to a SPIFF or do some other meaningful operation.
Beta Was this translation helpful? Give feedback.
All reactions