本文整理汇总了Python中werkzeug.debug.DebuggedApplication方法的典型用法代码示例。如果您正苦于以下问题:Python debug.DebuggedApplication方法的具体用法?Python debug.DebuggedApplication怎么用?Python debug.DebuggedApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.debug
的用法示例。
在下文中一共展示了debug.DebuggedApplication方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def run():
global application
app.debug = True
application = DebuggedApplication(application, evalex=True)
server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler)
server.serve_forever()
示例2: __call__
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def __call__(self, app, host, port, use_debugger, use_reloader, threaded, processes, passthrough_errors):
if use_debugger is None:
use_debugger = app.debug
if use_debugger is None:
use_debugger = True
if sys.stderr.isatty():
print("Debugging is on. DANGER: Do not allow random users to connect to this server.",
file=sys.stderr)
if use_reloader is None:
use_reloader = app.debug
if use_debugger:
from werkzeug.debug import DebuggedApplication
app = DebuggedApplication(app, True)
def run():
from gevent.wsgi import WSGIServer
gws = WSGIServer((host, port), app)
gws.base_env['wsgi.multithread'] = threaded
gws.base_env['wsgi.multiprocess'] = processes > 0
gws.serve_forever()
if use_reloader:
from werkzeug.serving import run_with_reloader
run_with_reloader(run)
else:
run()
示例3: __init__
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def __init__(self, *args, **kwargs):
super(DebugApplication, self).__init__(*args, **kwargs)
self.debug_app = DebuggedApplication(self, evalex=True)
self.debug_container = tornado.wsgi.WSGIContainer(self.debug_app)
示例4: cli
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def cli(info, host, port, reload, debugger, workers, worker_class):
os.environ['FLASK_RUN_FROM_CLI_SERVER'] = '1'
debug = flask.cli.get_debug_flag()
port = port or server_port()
host = host or server_bind_address()
options = {
'workers': workers or number_of_workers(),
'bind': '{}:{}'.format(host, port)
}
if worker_class is not None:
options["worker_class"] = worker_class
app = info.load_app()
if debug or debugger:
options["workers"] = 1
app.wsgi_app = DebuggedApplication(app.wsgi_app, True)
print(' * Launching in DEBUG mode')
print(' * Serving Flask using a single worker "{}"'.format(info.app_import_path))
if reload is None:
options["reload"] = bool(debug)
if debugger is None:
options["debug"] = bool(debug) or debugger
else:
print(' * Launching in Production Mode')
print(' * Serving Flask with {} worker(s) "{}"'.format(
options["workers"], info.app_import_path
))
server = GunicornStandalone(app, options=options)
server.run()
示例5: start
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def start(self):
# Wrap WSGI app with werkzeug debugger.
self.app.wsgi_app = wrap_wsgi_middleware(DebuggedApplication)(
self.app.wsgi_app)
thread = threading.Thread(target=self.run)
thread.start()
示例6: test_import_string
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def test_import_string(self):
import cgi
from werkzeug.debug import DebuggedApplication
self.assert_is(utils.import_string('cgi.escape'), cgi.escape)
self.assert_is(utils.import_string(u'cgi.escape'), cgi.escape)
self.assert_is(utils.import_string('cgi:escape'), cgi.escape)
self.assert_is_none(utils.import_string('XXXXXXXXXXXX', True))
self.assert_is_none(utils.import_string('cgi.XXXXXXXXXXXX', True))
self.assert_is(utils.import_string(u'cgi.escape'), cgi.escape)
self.assert_is(utils.import_string(u'werkzeug.debug.DebuggedApplication'), DebuggedApplication)
self.assert_raises(ImportError, utils.import_string, 'XXXXXXXXXXXXXXXX')
self.assert_raises(ImportError, utils.import_string, 'cgi.XXXXXXXXXX')
示例7: run
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def run(self, host=None, port=None, debug=None, **options):
import tornado.wsgi
import tornado.ioloop
import tornado.httpserver
import tornado.web
if host is None:
host = '127.0.0.1'
if port is None:
server_name = self.config['SERVER_NAME']
if server_name and ':' in server_name:
port = int(server_name.rsplit(':', 1)[1])
else:
port = 5000
if debug is not None:
self.debug = bool(debug)
hostname = host
port = port
application = self
use_reloader = self.debug
use_debugger = self.debug
if use_debugger:
from werkzeug.debug import DebuggedApplication
application = DebuggedApplication(application, True)
try:
from .webdav import dav_app
except ImportError as e:
logger.warning('WebDav interface not enabled: %r', e)
dav_app = None
if dav_app:
from werkzeug.wsgi import DispatcherMiddleware
application = DispatcherMiddleware(application, {
'/dav': dav_app
})
container = tornado.wsgi.WSGIContainer(application)
self.http_server = tornado.httpserver.HTTPServer(container)
self.http_server.listen(port, hostname)
if use_reloader:
from tornado import autoreload
autoreload.start()
self.logger.info('webui running on %s:%s', hostname, port)
self.ioloop = tornado.ioloop.IOLoop.current()
self.ioloop.start()
示例8: create_app
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def create_app(settings_override=None):
"""
Create a Flask application using the app factory pattern.
:param settings_override: Override settings
:return: Flask app
"""
app = Flask(__name__, instance_relative_config=True)
def disable_varnish(response):
response.cache_control.private = True
return response
app.after_request(disable_varnish)
SSLify(app, skips=['healthcheck'])
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
app.config.from_object('config.settings')
if 'GOOGLE_CLIENT_ID' in app.config:
setup_authentication(app)
app.register_blueprint(page)
plugins = {}
for plugin in app.config['ENABLED_PLUGINS']:
module = importlib.import_module(f'dashboard.plugins.{plugin}')
app.register_blueprint(module.plugin, url_prefix=module.base_path)
if hasattr(module, 'init'):
module.init(app)
plugins[plugin] = {'tab_name': module.tab_name}
app.airflow_data_provider = AirflowDBDataProvider(app.config, app.logger, MySQLClient(app.config, app.logger))
app.influx_client = InfluxDbService(app.config, app.logger) if app.config.get('INFLUXDB_HOST') else None
app.influx_data_provider = InfluxDBData(app.influx_client, app.logger) if app.config.get('INFLUXDB_HOST') else None
app.prometheus_data_provider = PrometheusData(app.config, app.logger) if app.config.get('PROMETHEUS_HOST') else None
# Reading tables configs, setting variable to `None` if file is not present
tables = get_yaml_file_content(TABLES_PATH)
app.table_data_provider = TableDataProvider(
app.airflow_data_provider, app.influx_data_provider,
app.prometheus_data_provider, tables, app.logger, app.config) if tables else None
links = get_yaml_file_content(LINKS_PATH)
app.links_data_provider = LinksDataProvider(links)
app.etl_data_provider = EtlDataProvider(
app.config, app.airflow_data_provider, app.table_data_provider)
app.async_request_executor = ThreadPoolExecutor(max_workers=3)
app.cache = SimpleCache()
if app.debug:
app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
app.context_processor(lambda: {'now': datetime.now(), 'plugins': plugins})
return app
示例9: run
# 需要导入模块: from werkzeug import debug [as 别名]
# 或者: from werkzeug.debug import DebuggedApplication [as 别名]
def run(app: flask.Flask, *,
host='127.0.0.1', port=None, debug=False, loop=None):
"""Run Flask application on aiohttp
:param app: Flask application
:param host: host name or ip
:param port: port (default is 5000)
:param debug: debug?
"""
# Check initialization status of flask app.
if getattr(app, 'aiohttp_app', None) is None:
raise RuntimeError(
"This application is not initialized for Flask-aiohttp. "
"Please initialize the app by `aio.init_app(app)`.")
# Configure args
if port is None:
server_name = app.config['SERVER_NAME']
if server_name and ':' in server_name:
port = int(server_name.rsplit(':', 1)[-1])
else:
port = 5000
loop = loop or asyncio.get_event_loop()
# Define run_server
def run_server():
# run_server can be called in another thread
asyncio.set_event_loop(loop)
coroutine = loop.create_server(
app.aiohttp_app.make_handler(), host, port)
loop.run_until_complete(coroutine)
try:
loop.run_forever()
except KeyboardInterrupt:
pass
# Configure logging
file_handler = logging.StreamHandler()
app.logger.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
if debug:
# Logging
app.logger.setLevel(logging.DEBUG)
# Wrap WSGI app with werkzeug debugger.
app.wsgi_app = wrap_wsgi_middleware(DebuggedApplication)(
app.wsgi_app)
if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
app.logger.info(' * Running on http://{}:{}/'
.format(host, port))
# Run with reloader
run_with_reloader(run_server)
else:
app.logger.info(' * Running on http://{}:{}/'.format(host, port))
run_server()