本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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")
示例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