-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver.py
More file actions
37 lines (26 loc) · 1.09 KB
/
httpserver.py
File metadata and controls
37 lines (26 loc) · 1.09 KB
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
33
34
35
36
37
import os
from bottle import TEMPLATE_PATH, route, run, template, redirect, request, response, abort, static_file
import threading
import json
import log
import phonestate
import sounds
import play
# This is unfinished, but should work if you uncomment the import line in magicphone.py and add some useful web stuff
# The templates and static files are at ./httpserver/
TEMPLATE_PATH.append('./httpserver/')
@route('/')
def index():
return template('root')
@route('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='./httpserver/', mimetype='application/javascript')
@route('/<filename:re:.*\.ico>')
def send_ico(filename):
return static_file(filename, root='./httpserver/', mimetype='image/x-icon')
@route('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='./httpserver/', mimetype='text/css')
# run(host='0.0.0.0', port=80, debug=True)
# run the server in a thread, otherwise it blocks here and prevents everything else from happening
threading.Thread(target=run, daemon=True, kwargs=dict(host='0.0.0.0', port=80)).start()