-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
66 lines (53 loc) · 1.49 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
57
58
59
60
61
62
63
64
65
66
from app_config import config
from app_tools import *
from application import *
import json
import bottle as btl
## TODO remove
from urllib.parse import quote
btl.BaseRequest.MEMFILE_MAX = config['size']
app = Application()
##############################################################################
#admin routes
##############################################################################
@btl.get('/userAuth')
def userAuth():
try:
data = btl.request.query['data']
return app.userAuth(data)
except:
return ""
@btl.get('/userData')
def userData():
#try:
data = btl.request.query['data']
print(data)
return app.userData(data)
#except:
#return config['error']['fuck']
@btl.get('/decode')
def decode():
data = btl.request.query['data']
data = base64.b64decode(data)
data = acrypt.crypt_rc4(str(data,'utf-8'), acrypt.key)
return data
@btl.get('/encode')
def encode():
data = btl.request.query['data']
data = acrypt.crypt_rc4(data, acrypt.key)
data = base64.b64encode(bytes(data, 'utf-8'))
data = quote(data, safe='')
return data
##############################################################################
#error routes
##############################################################################
@btl.error(404)
def error404(error):
return ''
@btl.error(405)
def error405(error):
return ''
btl.run(host=config['server_host'],
server = 'tornado',
port=config['server_port']
)