prepare public api
This commit is contained in:
parent
507b6fed3e
commit
dd0e22a979
18 changed files with 237 additions and 94 deletions
|
|
@ -95,7 +95,7 @@ def run():
|
|||
else:
|
||||
debug = False
|
||||
|
||||
log_format='%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
if debug:
|
||||
logging.basicConfig(level=logging.DEBUG, format=log_format)
|
||||
else:
|
||||
|
|
@ -109,7 +109,7 @@ def run():
|
|||
'gzip': True
|
||||
}
|
||||
|
||||
handlers = [
|
||||
common_handlers = [
|
||||
(r'/(favicon.ico)', StaticFileHandler, {'path': settings.static_path}),
|
||||
(r'/static/oxjs/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'oxjs')}),
|
||||
(r'/static/cbr.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'cbr.js')}),
|
||||
|
|
@ -126,17 +126,33 @@ def run():
|
|||
'attachment': True
|
||||
}),
|
||||
(r'/(.*)/(cover|preview)(\d*).jpg', IconHandler),
|
||||
]
|
||||
handlers = common_handlers + [
|
||||
(r'/api/upload/', UploadHandler, dict(context=db.session)),
|
||||
(r'/api/', oxtornado.ApiHandler, dict(context=db.session)),
|
||||
(r'/ws', websocket.Handler),
|
||||
(r"(.*)", MainHandler),
|
||||
]
|
||||
public_handlers = common_handlers + [
|
||||
(r'/api/', oxtornado.ApiHandler, dict(context=db.session, public=True)),
|
||||
(r'/ws', websocket.Handler, dict(public=True)),
|
||||
(r"(.*)", MainHandler),
|
||||
]
|
||||
|
||||
setup.create_db()
|
||||
http_server = Application(handlers, **options)
|
||||
max_buffer_size = 2*1024*1024*1024
|
||||
http_server.listen(settings.server['port'], settings.server['address'], max_buffer_size=max_buffer_size)
|
||||
|
||||
# public server
|
||||
'''
|
||||
public_port = settings.server.get('public_port')
|
||||
public_address = settings.server['public_address']
|
||||
if public_port:
|
||||
public_server = Application(public_handlers, **options)
|
||||
public_server.listen(public_port, public_address)
|
||||
'''
|
||||
|
||||
if PID:
|
||||
with open(PID, 'w') as pid:
|
||||
pid.write('%s' % os.getpid())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue