本文整理汇总了Python中paste.translogger.TransLogger方法的典型用法代码示例。如果您正苦于以下问题:Python translogger.TransLogger方法的具体用法?Python translogger.TransLogger怎么用?Python translogger.TransLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paste.translogger
的用法示例。
在下文中一共展示了translogger.TransLogger方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_server
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run_server():
# Enable WSGI access logging via Paste
app_logged = TransLogger(app)
# Mount the WSGI callable object (app) on the root directory
cherrypy.tree.graft(app_logged, '/')
# Set the configuration of the web server
cherrypy.config.update({
'engine.autoreload_on': True,
'log.screen': True,
'log.error_file': "cherrypy.log",
'server.socket_port': 5000,
'server.socket_host': '0.0.0.0',
'server.thread_pool': 50, # 10 is default
})
# Start the CherryPy WSGI web server
cherrypy.engine.start()
cherrypy.engine.block()
# Connection
示例2: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, handler): # pragma: no cover
from paste import httpserver
from paste.translogger import TransLogger
handler = TransLogger(handler, setup_console_handler=(not self.quiet))
httpserver.serve(handler, host=self.host, port=str(self.port),
**self.options)
示例3: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, handler): # pragma: no cover
from paste import httpserver
if not self.quiet:
from paste.translogger import TransLogger
handler = TransLogger(handler)
httpserver.serve(handler, host=self.host, port=str(self.port),
**self.options)
示例4: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, handler): # pragma: no cover
from paste import httpserver
from paste.translogger import TransLogger
handler = TransLogger(handler, setup_console_handler=(not self.quiet))
httpserver.serve(handler,
host=self.host,
port=str(self.port), **self.options)
示例5: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, handler): # 重写 run() 函数.
from paste import httpserver
from paste.translogger import TransLogger
app = TransLogger(handler)
httpserver.serve(app, host=self.host, port=str(self.port))
示例6: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, handler): # pragma: no cover
from paste import httpserver
from paste.translogger import TransLogger
app = TransLogger(handler)
httpserver.serve(app, host=self.host, port=str(self.port), **self.options)
示例7: run
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def run(self, netloc='0.0.0.0:9090', reload=True, log=True):
"""Run the CherryPy server."""
from django.conf import settings
from django.core.handlers.wsgi import WSGIHandler
from paste.translogger import TransLogger
url_parts = urlparse.urlsplit(netloc)
host = "0.0.0.0"
port = 9090
cherrypy.config.update({
'server.socket_host': host,
'server.socket_port': port,
'log.screen': False,
'engine.autoreload.on': reload,
'log.access_file': cherry_access_log,
'log.error_file': cherry_error_log,
})
self.cfg_assets(settings.MEDIA_URL, settings.MEDIA_ROOT)
self.cfg_assets(settings.STATIC_URL, settings.STATIC_ROOT)
self.cfg_favicon(settings.STATIC_ROOT)
app = WSGIHandler()
app = TransLogger(app, logger_name='cherrypy.access',
setup_console_handler=False)
if self.domains:
app = cherrypy.wsgi.VirtualHost(app, self.domains)
cherrypy.tree.graft(app)
cherrypy.engine.start()
示例8: start_cherrypy
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def start_cherrypy(app,
host=None,
port=None,
ssl_cert_file=None,
ssl_key_file=None,
is_dev_env=None):
if not is_dev_env:
cherrypy.config.update({'environment': 'production'})
cherrypy.config.update(config.get_cherrypy_config())
cherrypy.config.update({
'log.screen': False,
'server.socket_port': port,
'server.socket_host': host,
'server.ssl_certificate': ssl_cert_file,
'server.ssl_private_key': ssl_key_file
})
app_logged = TransLogger(app.wsgi_app, setup_console_handler=False)
cherrypy.tree.graft(app_logged, '/')
if not is_dev_env:
Daemonizer(cherrypy.engine).subscribe()
PIDFile(cherrypy.engine, os.path.join(util.get_user_directory(),
PID_FILE_NAME)).subscribe()
cherrypy.engine.start()
cherrypy.engine.block()
示例9: start_server
# 需要导入模块: from paste import translogger [as 别名]
# 或者: from paste.translogger import TransLogger [as 别名]
def start_server(self):
app = self.app
@app.route('/subtitles.vtt')
def subtitles():
# response = bottle.static_file(self.subtitles_fn, root='/', mimetype='text/vtt')
response = bottle.response
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET, HEAD'
response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
response.headers['Content-Type'] = 'text/vtt'
return self.subtitles
@app.get('/media/<id>.<ext>')
def video(id, ext):
print(list(bottle.request.headers.items()))
ranges = list(bottle.parse_range_header(bottle.request.environ['HTTP_RANGE'], 1000000000000))
print('ranges', ranges)
offset, end = ranges[0]
self.transcoder.wait_for_byte(offset)
response = bottle.static_file(self.transcoder.fn, root='/')
if 'Last-Modified' in response.headers:
del response.headers['Last-Modified']
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET, HEAD'
response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
return response
# app.run(host=self.ip, port=self.port, server='paste', daemon=True)
from paste import httpserver
from paste.translogger import TransLogger
handler = TransLogger(app, setup_console_handler=True)
httpserver.serve(handler, host=self.ip, port=str(self.port), daemon_threads=True)