forked from guiqiqi/Flaks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
32 lines (25 loc) · 809 Bytes
/
run.py
File metadata and controls
32 lines (25 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Simple running exmample"""
import json
from server import Request
from server import Response
from server import HTTPServer
from server import Application
Request.register_body_handler("text/json", json.loads)
httpd = HTTPServer(("0.0.0.0", 15014))
application = Application(__name__)
httpd.serve(application)
@application.route("/hello", methods=["GET"])
def test_get_function(request):
"""Hello World!"""
# __import__("time").sleep(10)
return \
"""
<html>
<body style="background: #dfe6e9; text-align:center;">
<h1 style="margin-top:30vh;">Hello World</h1>
<h3>From: Simple-Python-HTTP-Server</h3>
<h4 style="font-style: italic;">Your UA info: {UA}</h4>
</body>
</html>
""".format(UA=request.headers.get("User-Agent", ''))
httpd.start()