當前位置: 首頁>>代碼示例>>Python>>正文


Python web.Application類代碼示例

本文整理匯總了Python中aiohttp.web.Application的典型用法代碼示例。如果您正苦於以下問題:Python Application類的具體用法?Python Application怎麽用?Python Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Application類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

    async def init(loop):
        app = Application(loop=loop)
        app.router.add_route('POST', '/query', handle)

        handler = app.make_handler()
        srv = await loop.create_server(handler, conf['http_hostname'], conf['http_port'])
        return srv, handler
開發者ID:petrjanda,項目名稱:pysk,代碼行數:7,代碼來源:client.py

示例2: start_server

 def start_server(loop):
     app = Application(loop=loop)
     app.router.add_route(*handler.route)
     routes = app.router.routes()._urls
     assert len(routes), routes
     srv = yield from loop.create_server(app.make_handler(), "localhost", 9000)
     return srv
開發者ID:andrewyoung1991,項目名稱:django-redis-pubsub,代碼行數:7,代碼來源:test_testapp.py

示例3: init

async def init(loop):
    app = Application(loop=loop)
    app['sockets'] = {}
    print("Connecting to DB...")
    app['db'] = await db.create_db()
    print("Connected.")

    # HTML endpoint
    app.router.add_route('GET', '/', api.index.index)

    # Admin dashboard app management endpoints
    app.router.add_route('GET', '/apps', api.apps.get_all_apps)
    app.router.add_route('GET', '/apps/{app_id}', api.apps.get_app)
    app.router.add_route('POST', '/apps', api.apps.create_app)
    app.router.add_route('DELETE', '/apps/{app_id}', api.apps.delete_app)

    # Http lib endpoints
    # app.router.add_route('GET', '/apps/{app_id}/channels', '')
    # app.router.add_route('GET', '/apps/{app_id}/channels/{channel_name}', '')
    # app.router.add_route('GET', '/apps/{app_id}/channels/{channel_name}/users', '')
    # app.router.add_route('POST', '/apps/{app_id}/events', '')

    # Websocket and message endpoints
    app.router.add_route('GET', '/ws/{channel}', api.message.ws_handler)
    app.router.add_route('POST', '/apps/{app_id}/events', api.message.msg_handler)

    root = os.path.dirname(os.path.abspath(__file__))
    here = root + '/client/dist/assets'
    app.router.add_static('/assets', here)

    logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
    handler = app.make_handler(access_log=logging.getLogger('clang.access'))
    srv = await loop.create_server(handler, '127.0.0.1', 8040)
    print("Server started at http://127.0.0.1:8040")
    return app, srv, handler
開發者ID:Shellu,項目名稱:clang,代碼行數:35,代碼來源:clang.py

示例4: init

def init(loop):
    app = Application(loop=loop)
    app.router.add_route('GET', '/', simple)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '127.0.0.1', 8080)
    print("Server started at http://127.0.0.1:8080")
    return srv, handler
開發者ID:asvetlov,項目名稱:europython2015,代碼行數:8,代碼來源:aiohttp_server.py

示例5: init

def init(loop):
    app = Application(loop=loop, middlewares=[middleware_factory])
    app.router.add_route("GET", "/", handler)

    requests_handler = app.make_handler()
    srv = yield from loop.create_server(requests_handler, "127.0.0.1", 8080)
    print("Server started at http://127.0.0.1:8080")
    return srv, requests_handler
開發者ID:cclauss,項目名稱:aiohttp,代碼行數:8,代碼來源:web_rewrite_headers_middleware.py

示例6: init

async def init(loop):
    app = Application(loop=loop)
    app.router.add_route('GET', '/', handle)

    srv = await loop.create_server(app.make_handler(),
                                   '127.0.0.1', 1337)
    print('Server started at http://127.0.0.1:1337')
    return srv
開發者ID:alexeyraspopov,項目名稱:python-hot-swap,代碼行數:8,代碼來源:__main__.py

示例7: init

def init(loop):
    app = Application(loop=loop)
    app["sockets"] = []
    app.router.add_route("GET", "/", wshandler)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, "127.0.0.1", 8080)
    print("Server started at http://127.0.0.1:8080")
    return app, srv, handler
開發者ID:graingert,項目名稱:aiohttp,代碼行數:9,代碼來源:web_ws.py

示例8: webserver

def webserver(loop):
    app = Application(loop=loop)

    app.router.add_route('GET', '/eventsource/', eventsource)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '127.0.0.1', args.eventsource)
    logging.info("Eventsource started at http://127.0.0.1:{}".format(args.eventsource))
    return srv, handler
開發者ID:MartijnBraam,項目名稱:drush-queued,代碼行數:9,代碼來源:__main__.py

示例9: init

def init(loop):
    app = Application(loop=loop)
    wsgi_handler = WSGIHandler(django_app)

    app.router.add_route('*', '/ws/myjrpc', MyJsonRpc)
    app.router.add_route('*', '/ws/mydajrpc', MyDjangoAuthJsonRpc)
    app.router.add_route('*', '/{path_info:.*}', wsgi_handler.handle_request)

    yield from loop.create_server(app.make_handler(), '', 8080)
開發者ID:basti2342,項目名稱:aiohttp-json-rpc,代碼行數:9,代碼來源:server.py

示例10: init

def init(loop):
    app = Application(loop=loop)
    app['sockets'] = []
    app.router.add_route('GET', '/wfb', wshandler)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '127.0.0.1', 8001)
    print("Server started at http://127.0.0.1:8080")
    return app, srv, handler
開發者ID:bossjones,項目名稱:etc-python,代碼行數:9,代碼來源:web_ws.py

示例11: init

def init(loop):
    app = Application(middlewares=[session_middleware(
        EncryptedCookieStorage(SECRET_KEY))])
    setup_jinja(app, loader=FileSystemLoader(TEMPLATE_DIR))
    for route in routes:
        app.router.add_route(route['method'], route['url'], route['handler'], **route['kwargs_'])
    srv = yield from loop.create_server(
        app.make_handler(), '0.0.0.0', 8080)
    return srv
開發者ID:YGeeneY,項目名稱:tic_tac_toe,代碼行數:9,代碼來源:server.py

示例12: init

async def init(loop):
    app = Application(loop=loop)
    app['connections'] = {}
    app.router.add_route('GET', '/', ws_handler)

    handler = app.make_handler()
    srv = await loop.create_server(handler, '127.0.0.1', '8000')
    print("Server running on 127.0.0.1:8000")
    return app, srv, handler
開發者ID:tao12345666333,項目名稱:Talk-Is-Cheap,代碼行數:9,代碼來源:ws.py

示例13: main

def main(loop):
    app = Application(loop=loop)
    app.router.add_route('GET', '/', user_info)
    app.router.add_route('GET', '/group_id', user_group_id)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '127.0.0.1', 8888)
    print("Server started at http://127.0.0.1:8888")
    return srv, handler
開發者ID:JSFansw,項目名稱:wechatpy,代碼行數:9,代碼來源:app.py

示例14: init

def init(loop):
    global handler
    app = Application(loop=loop)
    app.router.add_route('GET', '/', handle_get)
    app.router.add_route('POST', '/IPN', handle_ipn)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '0.0.0.0', 8080)
    logging.info("IPN Server started at http://0.0.0.0:8080")
開發者ID:Avatarchik,項目名稱:netwrok-server,代碼行數:9,代碼來源:ipn.py

示例15: init

def init(loop, args):
    app = Application(loop=loop)
    app['sockets'] = []
    app.router.add_route('GET', '/', wsHandler)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, args.host, args.port)
    print("Server started at http://{}:{}".format(args.host, args.port))
    return app, srv, handler
開發者ID:cphyc,項目名稱:andremote,代碼行數:9,代碼來源:web_ws.py


注:本文中的aiohttp.web.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。