We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get the error mentioned in the title after a while running main.py with the following code:
import machine import time from phew import server, connect_to_wifi from phew.template import render_template
machine.Pin(13, machine.Pin.IN) machine.Pin(18, machine.Pin.IN)
connect_to_wifi("SSID", "PASSWORD")
@server.route("/passagem", methods=["GET", "POST"]) def passagem(request):
post = request.data.get("value", None) password = request.form.get("password", None)
if(post=="door1"): machine.Pin(18, machine.Pin.OUT) time.sleep(1) machine.Pin(18, machine.Pin.IN)
elif(post=="door2"): machine.Pin(13, machine.Pin.OUT) time.sleep(1) machine.Pin(13, machine.Pin.IN)
if(password == "password"): return render_template("index.html"), 200
else: return render_template("login.html"), 200
@server.route("/favicon.png", methods=["GET"]) def favicon(request): return render_template("favicon.png"), 200
@server.catchall() def catchall(request): return "Not found", 404
server.run()
The text was updated successfully, but these errors were encountered:
Refactoring _async def parse_headers in server.py worked for my project:
async def _parse_headers(reader): headers = {} while True: header_line = await reader.readline() if header_line == b"\r\n": break try: name, value = header_line.decode().strip().split(": ", 1) except ValueError as ex : return headers headers[name.lower()] = value return headers
Do not forget to adjust intent because it is 2 whitespaces in server.py.
Sorry, something went wrong.
No branches or pull requests
I get the error mentioned in the title after a while running main.py with the following code:
import machine
import time
from phew import server, connect_to_wifi
from phew.template import render_template
machine.Pin(13, machine.Pin.IN)
machine.Pin(18, machine.Pin.IN)
connect_to_wifi("SSID", "PASSWORD")
@server.route("/passagem", methods=["GET", "POST"])
def passagem(request):
post = request.data.get("value", None)
password = request.form.get("password", None)
if(post=="door1"):
machine.Pin(18, machine.Pin.OUT)
time.sleep(1)
machine.Pin(18, machine.Pin.IN)
elif(post=="door2"):
machine.Pin(13, machine.Pin.OUT)
time.sleep(1)
machine.Pin(13, machine.Pin.IN)
if(password == "password"):
return render_template("index.html"), 200
else:
return render_template("login.html"), 200
@server.route("/favicon.png", methods=["GET"])
def favicon(request):
return render_template("favicon.png"), 200
@server.catchall()
def catchall(request):
return "Not found", 404
server.run()
The text was updated successfully, but these errors were encountered: