-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
56 lines (40 loc) · 1.03 KB
/
server.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import sys
import logging
import web
#enforce import of web.http, o/w py2exe don't understand it need to package it.
import web.http
import json
import time
import mimerender
import jsonpickle
import fnmatch
import socket
import control
mimerender = mimerender.WebPyMimeRender()
# JSON wrapper for @mimerender
render_txt = lambda message: message
logger = logging.getLogger('server')
class GetInfo:
def GET(self, arg):
print arg
ret = control.main(arg)
print ret
return ret
#return control.main(arg)
### Server Methods ###
"""
For each url class, we should add here a pair of 'url','class_name'
"""
urls = (
'/search=(.+)', GetInfo.__name__,
)
if __name__ == "__main__":
try:
app = web.application(urls, globals())
app.run()
except socket.error as e:
print "error: no socket could be created"
print "port might be bind already"
logger.error("Exception raised: " + e.message, exc_info=True)
os._exit(0)