forked from Darknights-dev/Darknights-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (54 loc) · 1.41 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
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
67
68
69
70
71
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Conjecture is impossible. You have the right to reject this story.
import os
import json
from bottle import *
from core import *
from utils import logger
base_path = os.path.dirname(os.path.realpath(__file__)) # base dir
listen_port = 9444 # handle all ak server
domain_name = "example.com"
HTML = \
"""
Great ideals but through selfless struggle and sacrifice to achieve.
"""
# EntryPoint
@route('/')
@route('/index.html')
def index():
return HTML
@route('/announce/IOS/preannouncement.meta.json')
@route('/announce/Android/preannouncement.meta.json')
def ann():
resp = """
{
"actived": true,
"preAnnounceId": 280,
"preAnnounceType": 2,
"preAnnounceUrl": ""
}
"""
medium = json.loads(resp)
medium['preAnnounceUrl'] = "https://" + domain_name + "/announce/Android/preannouncement/280.html"
return medium
@route('/announce/Android/preannouncement/280.html')
@route('/announce/IOS/preannouncement/280.html')
def announce():
return HTML
# Handle Error
@error(404)
def error404(error):
logger.info(str(error), request.environ.get('HTTP_X_FORWARDED_FOR'))
print(error)
return "404 Not Found"
@error(500)
def error500(error):
logger.info(str(error), request.environ.get('HTTP_X_FORWARDED_FOR'))
return '500 Internal Error'
run(
host='0.0.0.0',
debug=True,
port=listen_port,
reloader=True
)