Files
microdot/examples/hello.py
Damien George c5e1873523 Move socket import, remove Request.G, and add simple hello example (#12)
* Further guard import of socket to make it optional

This is so that systems without a (u)socket module can still use Microdot.
For example if the transport layer is provided by a serial link.

* Add simple hello.py example that serves a static HTML page
2020-06-30 23:23:17 +01:00

27 lines
502 B
Python

from microdot import Microdot, Response
app = Microdot()
htmldoc = """<!DOCTYPE html>
<html>
<head>
<title>Microdot Example Page</title>
</head>
<body>
<div>
<h1>Microdot Example Page</h1>
<p>Hello from Microdot!</p>
</div>
</body>
</html>
"""
@app.route("", methods=["GET", "POST"])
def serial_number(request):
print(request.headers)
return Response(body=htmldoc, headers={"Content-Type": "text/html"})
app.run(debug=True)