* 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
27 lines
502 B
Python
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)
|