opsv2/settings.py
2020-12-01 18:17:07 +08:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python
# encoding: utf-8
from os import path
from urls import urls_pattern as url_handlers
from tornado.log import access_log
#import logging
DEBUG = False
def log_func(handler):
if handler.get_status() < 400:
log_method = access_log.info
elif handler.get_status() < 500:
log_method = access_log.warning
else:
log_method = access_log.error
request_time = 1000.0 * handler.request.request_time()
log_method("%d %s %s (%s) %s %s %.2fms", handler.get_status(), handler.request.method, handler.request.uri,
handler.request.remote_ip, handler.request.headers["User-Agent"], handler.request.arguments,
request_time)
# the application settings
settings = {'debug': DEBUG, 'cookie_secret': 'test', # TODO: get the real secret
'login_url': '/admin/login', 'xsrf_cookies': True,
'static_path': path.join(path.dirname(__file__), 'static_v1'),
'template_path': path.join(path.dirname(__file__), 'templates'), "log_function": log_func
# 'ui_modules': '' # TODO: the ui modules file
}