I'm using an ESP32 CAM for an aplication which must connect to wifi. The main idea is to create a friendly user interface to enter the ssid and password using the ESP in AP_mode in its first use, where the user have to connect to it, and finally entry data in a exposed web served page using a web browser.
I am asking for:
1) How to solve the following not working propossed code
2) An alternative or example to implement what I am looking for.
1)At the moment I'm using picoweb with the following code. (ESP in AP mode) I can run it calling app.run(debug=1, host = "192.168.4.1" ) and print into REPL the ssid and pasword entered but I can not exit the running app to continue with the main program. I have thougth to launch the app in a threading and kill it at the end as an alternative, but seems to be a dirty way. Any suggestion to finish the app execution?
Code: Select all
app = picoweb.WebApp(__name__) @app.route("/") def index(req, resp): global settings if req.method == "POST": print("request is post") yield from req.read_form_data() settings["ssid"] = req.form.get('ssid') settings["password"] = req.form.get('password') flag_params = True yield from resp.awrite("Connect Form received") print(settings) else: yield from picoweb.start_response(resp) f = open('NetworkForm.html') http_form= f.read() yield from resp.awrite(http_form) @app.route("/squares") def squares(req, resp): yield from picoweb.start_response(resp) yield from app.render_template(resp, "squares.tpl", (req,))