当前位置: 首页>>代码示例>>Python>>正文


Python werkzeug.serving方法代码示例

本文整理汇总了Python中werkzeug.serving方法的典型用法代码示例。如果您正苦于以下问题:Python werkzeug.serving方法的具体用法?Python werkzeug.serving怎么用?Python werkzeug.serving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug的用法示例。


在下文中一共展示了werkzeug.serving方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_app

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import serving [as 别名]
def test_app(environ, start_response):
    """Simple test application that dumps the environment.  You can use
    it to check if Werkzeug is working properly:

    .. sourcecode:: pycon

        >>> from werkzeug.serving import run_simple
        >>> from werkzeug.testapp import test_app
        >>> run_simple('localhost', 3000, test_app)
         * Running on http://localhost:3000/

    The application displays important information from the WSGI environment,
    the Python interpreter and the installed libraries.
    """
    req = Request(environ, populate_request=False)
    if req.args.get("resource") == "logo":
        response = logo
    else:
        response = Response(render_testapp(req), mimetype="text/html")
    return response(environ, start_response) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:testapp.py

示例2: test_app

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import serving [as 别名]
def test_app(environ, start_response):
    """Simple test application that dumps the environment.  You can use
    it to check if Werkzeug is working properly:

    .. sourcecode:: pycon

        >>> from werkzeug.serving import run_simple
        >>> from werkzeug.testapp import test_app
        >>> run_simple('localhost', 3000, test_app)
         * Running on http://localhost:3000/

    The application displays important information from the WSGI environment,
    the Python interpreter and the installed libraries.
    """
    req = Request(environ, populate_request=False)
    if req.args.get('resource') == 'logo':
        response = logo
    else:
        response = Response(render_testapp(req), mimetype='text/html')
    return response(environ, start_response) 
开发者ID:jpush,项目名称:jbox,代码行数:22,代码来源:testapp.py

示例3: init_werkzeug_server

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import serving [as 别名]
def init_werkzeug_server(app, port, host):
    try:
        import werkzeug
    except ImportError:
        raise ImportError(
            'Capybara\'s werkzeug server is unable to load `werkzeug`, please install the package '
            'and add `werkzeug` to your requirements.txt file.')

    from werkzeug.serving import make_server
    from logging import getLogger

    # Mute the server.
    log = getLogger('werkzeug')
    log.disabled = True

    server = make_server(host, port, app, threaded=True)

    # Inform Python that it shouldn't wait for request threads to terminate before
    # exiting. (They will still be appropriately terminated when the process exits.)
    server.daemon_threads = True

    server.serve_forever() 
开发者ID:elliterate,项目名称:capybara.py,代码行数:24,代码来源:__init__.py

示例4: handle_untag

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import serving [as 别名]
def handle_untag(request, tag_name, metric_name):
    res = metrics.untag(metric_name, tag_name)

    return "deleted" if res else "not deleted"


# useful to run standalone with werkzeug's server:
# $ python -m werkzeug.serving appmetrics.wsgi.standalone_app
# * Running on http://127.0.0.1:5000/ 
开发者ID:avalente,项目名称:appmetrics,代码行数:11,代码来源:wsgi.py

示例5: run_command

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import serving [as 别名]
def run_command(info, host, port, reload, debugger, eager_loading,
                with_threads, cert):
    """Run a local development server.

    This server is for development purposes only. It does not provide
    the stability, security, or performance of production WSGI servers.

    The reloader and debugger are enabled by default if
    FLASK_ENV=development or FLASK_DEBUG=1.
    """
    debug = get_debug_flag()

    if reload is None:
        reload = debug

    if debugger is None:
        debugger = debug

    if eager_loading is None:
        eager_loading = not reload

    show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)

    from werkzeug.serving import run_simple
    run_simple(host, port, app, use_reloader=reload, use_debugger=debugger,
               threaded=with_threads, ssl_context=cert) 
开发者ID:PacktPublishing,项目名称:Building-Recommendation-Systems-with-Python,代码行数:29,代码来源:cli.py


注:本文中的werkzeug.serving方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。