-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
31 lines (24 loc) · 827 Bytes
/
server.py
File metadata and controls
31 lines (24 loc) · 827 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
from lync import *
from apps.gws import GoogleSearch
from apps.fs import StaticFile
import json
def log(tag, msg):
print('[%s] [%s] %s' % (time.asctime(), tag, msg))
class console(object):
debug = functools.partial(log, 'DEBUG')
info = functools.partial(log, 'INFO')
warn = functools.partial(log, 'WARN')
error = functools.partial(log, 'ERROR')
if __name__ == '__main__':
try:
with open('server.json') as f:
conf = json.load(f, 'utf-8')
except:
conf = WebServerConfiguration()
console.warn('file server.json is not found, using default configurations.')
server = WebServer(logging=console, conf=conf)
gws = GoogleSearch('www.google.com.hk')
fs = StaticFile('www/', {})
server.install(gws, '/search')
server.install(fs)
server.run()