-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
32 lines (28 loc) · 1.04 KB
/
main.py
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
import os
import logging as log
from bottle import default_app, route, request, view, static_file, run
@route("/")
@view("base")
def default():
result = {}
table = ['<table class="u-full-width"><tbody>']
for k, v in sorted(os.environ.items()):
table.append('<tr><th>%s</th><td>%s</td></tr>' % (k, v))
table.append('</tbody></table>')
result['sys_data'] = '\n'.join(table)
table = ['<table class="u-full-width"><tbody>']
for k, v in sorted(dict(request.environ).items()):
table.append('<tr><th>%s</th><td>%s</td></tr>' % (k, v))
table.append('</tbody></table>')
result['req_data'] = '\n'.join(table)
return result
@route("/<path:path>")
def static(path):
return static_file(path, root="static")
app = default_app()
if __name__ == '__main__':
log.debug("Beginning run.")
HTTP_PORT = int(os.environ.get('PORT', 8000))
BIND_ADDRESS = os.environ.get('BIND_ADDRESS', '127.0.0.1')
DEBUG = 'true' == os.environ.get('DEBUG', 'false').lower()
run(host=BIND_ADDRESS, port=HTTP_PORT, debug=DEBUG)