forked from gislite/maplet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
71 lines (54 loc) · 1.9 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
67
68
69
70
71
# coding:utf-8
import tornado.autoreload
import tornado.ioloop
import tornado.locale
import sys
import os
import tornado.web
from urls import urls
from torlite.modules.modef import core_modules as modules
import config
from maplet.modules.extends import *
modules['rel_post2app'] = rel_post2app
modules['rel_app2post'] = rel_app2post
modules['app_most_used'] = app_most_used
modules['app_random_choose'] = app_random_choose
modules['app_tags'] = app_tags
modules['app_menu'] = app_menu
modules['app_user_recent'] = app_user_recent
modules['app_user_most'] = app_user_most
modules['app_recent_used'] = app_recent_used
modules['label_count'] = label_count
modules['amazon_ad'] = amazon_ad
modules['baidu_search'] = baidu_search
modules['site_ad'] = site_ad
modules['widget_search'] = widget_search
modules['app_most_used_by_cat'] = app_most_used_by_cat
modules['app_least_used_by_cat'] = app_least_use_by_cat
modules['app_user_recent_by_cat'] = app_user_recent_by_cat
SETTINGS = {
"template_path": os.path.join(os.path.dirname(__file__), "templates"),
"static_path": os.path.join(os.path.dirname(__file__), "static"),
'debug': True,
"cookie_secret": config.cookie_secret,
"login_url": "/user/login",
'ui_modules': modules,
}
PORT = '8246'
if __name__ == "__main__":
tornado.locale.set_default_locale('zh_CN')
tornado.locale.load_gettext_translations('locale', 'yunsuan')
if len(sys.argv) > 1:
PORT = sys.argv[1]
# 此处为解决手机站的问题
if PORT[1] == '1':
# 形如: 8188, 8199
SETTINGS['template_path'] = os.path.join(os.path.dirname(__file__), "templates_m")
application = tornado.web.Application(
handlers=urls,
**SETTINGS
)
application.listen(PORT)
print ('Development server is running at http://127.0.0.1:{0}/'.format(PORT))
print ('Quit the server with CONTROL-C')
tornado.ioloop.IOLoop.instance().start()