Hi all,
I am making a project that uses ESP32 camera and image processing with Python. I need to send a post request with some data in it to the camera. My code is the following:
AsyncWebServer server(82);
...
server.on("/data", HTTP_POST, [](AsyncWebServerRequest * request){}, NULL,
[](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) {
Serial.println("POST request received");
StaticJsonDocument<20> JSONBuffer;
deserializeJson(JSONBuffer, data);
JsonObject obj = JSONBuffer.as<JsonObject>();
String response = obj["data"];
assignResponse(response);
request->send(200, "text/plain", "Data from esp32cam image processing");
});
Serial.println(response);
server.begin();
...
requests.post('{IP_address}/data', data = "{'data': 'yes'}")
Since I use an async web server, the serial prints first the empty variable response and then when the response comes it is assigned. I need to access the response variable after the request. Do I need to use some kind of a normal Wifi/Web server or is there a simple way to handle that post request to the esp camera?