Someone would have to guess the name of the page. So don 't use index.html
Okay, thats a solution. Thank you!
Only sufficient if you're not really that concerned about someone gaining access to the camera.
I'm not. I don't want to protect the camera data neither, but just the main configuration page. I have some people around me who would have much fun to trick me in which changing the camera config. If somebody want to take a look at the camera pictures or stream, he can do, if he want, because it will just display some birds like a trail-camera.
For everyone who has the same problem, here how to incorporate the code from @ZX80 into app_httpd.cpp of the CameraWebServer Example:
Just insert the piece of code at the beginning of the sketch. You can change the username and password into the code at line 32. The site which will be opened if credentials are correct can be changed in line 34. Then change in the function void startCameraServer()
in the structure index_uri the handler into "password_handler" or something like that.
httpd_uri_t index_uri = {
.uri = "/",
.method = HTTP_GET,
.handler = password_handler,
.user_ctx = NULL
};
You have to add a new struct like this with a variable .uri-site and "index_handler" as .handler.
You have to do the same with all pages which you want to protect with a password.
Further up, create a new function called "password_handler":
static esp_err_t password_handler(httpd_req_t *req) {
httpd_resp_set_type(req, "text/html");
httpd_resp_send(req, loginIndex, HTTPD_RESP_USE_STRLEN);
}
If somebody with the same problem has questions about my solution, feel free to contact me. Thank's to everybody who helped me!