def setup_routes(app: Application): app.add_routes([ view('/group/{id}', GroupView), view('/group', GroupView), view('/contact/{id}', ContactView), view('/contact', ContactView) ])
def init_routes(app_authenticate: web.Application) -> None: app_authenticate.add_routes([ web.view('/login', apis.Login, name='login'), # type: ignore web.view('/refresh-token', apis.RefreshToken, name='refresh-token'), # type: ignore web.view('/logout', apis.Logout, name='logout') # type: ignore ])
def setup_routes(app): routes = [ web.view(FDSNWS_DATASELECT_PATH_QUERY, RedirectView), web.view(FDSNWS_STATION_PATH_QUERY, RedirectView), web.view(EIDAWS_WFCATALOG_PATH_QUERY, RedirectView), ] app.add_routes(routes)
def inject_routes(app: web.Application) -> None: """Инициализация роутов.""" app.add_routes([ web.view("/heartbeat", HealthView), web.view("/checkstatus", CheckStatus), web.view("/creategoods", CreateGoods), web.view("/updategoods", CreateGoods) ])
def init_routes(self, app: web.Application): app.add_routes([ web.view('/', IndexView), web.view('/api/v1/user', UserView), web.view('/api/v1/user/{user_id}', GetUserView), web.view('/api/v1/reports', ReporterView) ]) setup_aiohttp_apispec(app=app, **self.config['swagger'])
def inject_routes(app: web.Application) -> None: """Инициализация роутов.""" app.add_routes( [ web.view("/heartbeat", HealthView), web.view("/add", InsertInfo), web.view("/status", GetInfo) ] )
def createApp(self): app = web.Application() app.gApp = self.app app.router.add_routes([ web.view('/graphs/{g:.*}/{fmt:.*}', GraphsView), web.view('/{obj:.*}', RootView) ]) return app
def setup_routes(app): resources = [ web.view(r"/dishes", IndexView), web.view(r"/dishes/add", AddDishView), web.view(r"/dishes/settings", SettingsView), web.view(r"/dishes/{dish_id:\d+}", DelegateView), web.static(r"/static/", str(ROOT_FOLDER) + '/dishes/resources') ] app.add_routes(resources)
def setup_routes(app): app.add_routes( [ web.view('/wechat/message', WeMessageHandle), web.view('/wechat/chat', WeChatHandle), web.view('/wechat/group', WeGroupHandle), web.view('/health', HealthCheckHandle) ] ) setup_swagger(app, swagger_from_file="example_swagger.yaml")
async def get_application(): app = web.Application(debug=False) await init_db(app) app.add_routes([ web.view('/restaurants', RestaurantsView), web.view('/restaurant/{restaurant_id:\d+}', RestaurantView), ]) return app
def run(argv): app = web.Application() app["thread_executor"] = ThreadPoolExecutor(max_workers=WORKER, thread_name_prefix="support_") app.router.add_routes([ web.view("/plus", PlusDataView), web.view("/mult", MultDataView), ]) app.on_startup.append(on_start) app.on_cleanup.append(on_down) return app
def setup_routes(app: web.Application) -> None: """ Установка маршрутов для взаимодействия с приложением. :param app: экземпляр aiohttp-приложения """ app.router.add_routes([ web.post(r'/login', views.LoginView), web.view(r'/products', views.ProductListCreateView), web.view(r'/products/{slug}', views.ProductRetrieveUpdateDeleteView), web.view(r'/orders', views.OrderListCreateView), web.view(r'/orders/{number:\d+}', views.OrderRetrieveUpdateDeleteView) ])
async def resto_app(cfg): app = web.Application(middlewares=[json_middleware]) app['cfg'] = cfg app.on_startup.append(create_connection_pool) app.on_startup.append(create_collections) app.on_cleanup.append(dispose_connection_pool) app.add_routes([ web.view('/restaurants', RestaurantsView), web.view('/restaurants/{name}', RestaurantsView) ]) return app
def build_urls(prefix=''): return [ web.view(f'{prefix}/', views.CreateWishlistView), web.view( f'{prefix}/' r'{wishlist_id:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}}/', # noqa views.GetWishlistView), web.view( f'{prefix}/' r'{wishlist_id:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}}/' # noqa r'{sku:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}}/', # noqa views.ItemWishlist), ]
def main(): parser = argparse.ArgumentParser(description='Pyide args') parser.add_argument('--host', metavar='host', type=str, default='0.0.0.0', help='Host name') parser.add_argument('-p', '--port', metavar='port', type=int, default=31415, help='Listen port number') parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode') args = parser.parse_args() settings = {'debug': args.debug} if args.debug: logging.basicConfig(level=logging.DEBUG) app = web.Application(**settings) app.add_routes( [ # web.view(ROUTING['command'], Command), web.view(ROUTING['filelisting'] + '/{file_name:.*}', FileListing), web.view(ROUTING['filelisting'], FileListing), web.view(ROUTING['code'] + '/{file_name:.*}', Code), web.view(ROUTING['tags'] + '/{file_name:.*}', Tags), web.view(ROUTING['gotodefinition'] + '/{file_name:.*}', GoToDefinition), web.view(ROUTING['line'] + '/{file_name:.*}', Line), web.view(ROUTING['autocomplete'] + '/{file_name:.*}', AutoComplete), web.static('/client', ROUTING['client']), web.view(ROUTING['favicon'], Favicon) ] ) web.run_app(app, host=args.host, port=args.port)
def setup_routes(app): app.add_routes((web.view('/youtube/storedvideos', youtube.StoredVideos), web.view('/youtube/search', youtube.SearchVideos))) cors = aiohttp_cors.setup(app, defaults={ '*': aiohttp_cors.ResourceOptions( allow_credentials=True, expose_headers='*', allow_headers='*') }) for route in list(app.router.routes()): cors.add(route, webview=True)
def create_app(): """ Create basic application, define API endpoints :return: web app """ ws = WebSockets(log) csrf_policy = aiohttp_csrf.policy.FormPolicy(CSRFCongiruation.FORM_FIELD_NAME) csrf_storage = aiohttp_csrf.storage.CookieStorage(CSRFCongiruation.COOKIE_NAME) app = Application(middlewares=[auth_middleware]) app.add_routes( routes=[ # Render web.get("/register", Register.get), web.get("/login", Login.get), web.get("/chat", Chat.get), web.get("/", Home.get), # Api web.post("/api/register", Register.post), web.post("/api/login", Login.post), web.post("/api/logout", Logout.post), web.get("/api/chat/ws", ws.get), web.get("/api/health", HealthCheck.get), # Static web.static("/static/js", path=DefaultPaths.STATIC_JS, append_version=True), # Feedback web.view("/feedback", Feedback), ] ) aiohttp_csrf.setup(app, policy=csrf_policy, storage=csrf_storage) app.middlewares.append(csrf) return app
async def test_web_view(aiohttp_client): app = web.Application() class MyView(web.View): async def get(self): return web.Response() async def post(self): return web.Response() app.router.add_routes([web.view("/a", MyView)]) client = await aiohttp_client(app) r = await client.get("/a") assert r.status == 200 await r.release() r = await client.post("/a") assert r.status == 200 await r.release() r = await client.put("/a") assert r.status == 405 await r.release()
def get_agent_routes(app) -> list: """ Get the standard list of routes for the von-x agent """ handler = AgentHandler(app['manager']) routes = [] routes.extend([ web.get('/chooser', handler.render_chooser), web.post('/chooser2', handler.process_chooser), web.post('/chooser3', handler.process_chooser), web.get('/search_credential/{org_name}', handler.search_credential), web.get('/search_credential/{org_name}/{service_name}', handler.search_credential), web.get('/filter_credential/{org_name}/{service_name}', handler.filter_credential), ]) # add routes for all configured forms routes.extend( web.view(form['path'] + '/{org_name}', form_handler(form, handler), name=form['name'] + '-ivy') for form in handler.forms) return routes
def add_routes(app, **kwargs): bot = app.get("bot") if bot is None: log.warning('[Web] No bot provided, bot status endpoints not ' 'included.') return class BotStatus(web.View): async def get(self): latencies = dict(bot.latencies) stats = dict() for shard_id in latencies: shard_status = dict(self.get_shard_stats(shard_id)) shard_status['latency'] = latencies[shard_id] stats[shard_id] = shard_status return web.json_response({"shards": stats}) def get_shard_stats(self, shard_id): counters = collections.Counter() counters['Shard'] = shard_id for guild in bot.guilds: if guild.shard_id != shard_id: continue guild_counts = bot.guild_counters[guild.id] counters['guilds'] += 1 counters['members'] += guild.member_count counters['messages'] += guild_counts[ CounterKeys.MESSAGES_RECIEVED] if any(guild.me in vc.members for vc in guild.voice_channels): counters['music'] += 1 return counters app.add_routes([web.view('/bot/status', BotStatus)])
def _get_session(self, connector: TCPConnector) -> BaseTestClient: app = Application() app.add_routes([view('/1.0/certificates', CertificatesView)]) server = TestServer(app, ) return BaseTestClient(server, )
async def test_web_view(aiohttp_client): app = web.Application() class MyView(web.View): async def get(self): return web.Response() async def post(self): return web.Response() app.router.add_routes([ web.view("/a", MyView) ]) client = await aiohttp_client(app) r = await client.get("/a") assert r.status == 200 await r.release() r = await client.post("/a") assert r.status == 200 await r.release() r = await client.put("/a") assert r.status == 405 await r.release()
async def setup_routes(app, handler): h = handler client = h.client index_all = index_settings['index_all'] index_private = index_settings['index_private'] index_group = index_settings['index_group'] index_channel = index_settings['index_channel'] exclude_chats = index_settings['exclude_chats'] include_chats = index_settings['include_chats'] routes = [ web.get('/', h.home) ] if index_all: #print(await client.get_dialogs()) async for chat in client.iter_dialogs(): alias_id = None if chat.id in exclude_chats: continue entity = chat.entity if isinstance(entity, User) and not index_private: print(f'{chat.title}, private: {index_private}') continue elif isinstance(entity, Channel) and not index_channel: print(f'{chat.title}, channel: {index_channel}') continue elif isinstance(entity, Chat) and not index_group: print(f'{chat.title}, group: {index_group}') continue alias_id = h.generate_alias_id(chat) p = "/{chat:" + alias_id + "}" routes.extend([ web.get(p, h.index), web.get(p + r"/logo", h.logo), web.get(p + r"/{id:\d+}/view", h.info), web.get(p + r"/{id:\d+}/download", h.download_get), web.head(p + r"/{id:\d+}/download", h.download_head), web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get), ]) log.debug(f"Index added for {chat.id} at /{alias_id}") else: for chat_id in include_chats: chat = await client.get_entity(chat_id) alias_id = h.generate_alias_id(chat) p = "/{chat:" + alias_id + "}" routes.extend([ web.get(p, h.index), web.get(p + r"/logo", h.logo), web.get(p + r"/{id:\d+}/view", h.info), web.get(p + r"/{id:\d+}/download", h.download_get), web.head(p + r"/{id:\d+}/download", h.download_head), web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get), ]) log.debug(f"Index added for {chat.id} at /{alias_id}") routes.append(web.view(r'/{wildcard:.*}', h.wildcard)) app.add_routes(routes)
def setup_routes(app, static=False): routes = [web.view(FED_WFCATALOG_PATH_QUERY, WFCatalogView)] if static: path_static = pathlib.Path(__file__).parent / FED_STATIC append_static_routes(app, routes, FED_WFCATALOG_PATH_JSON, path_static) app.add_routes(routes)
def setup_routes(app, static=False): routes = [ web.view(FED_AVAILABILITY_GEOCSV_PATH_QUERY, AvailabilityQueryView), web.view(FED_AVAILABILITY_GEOCSV_PATH_EXTENT, AvailabilityExtentView), ] if static: path_static = pathlib.Path(__file__).parent / FED_STATIC append_static_routes( app, routes, FED_AVAILABILITY_PATH_GEOCSV, path_static, follow_symlinks=True, ) app.add_routes(routes)
async def app_test_mixin(loop, public_key): app = web.Application() init_app_auth(app, public_key=public_key, jwt_header_prefix=JWT_HEADER_PREFIX, user_model=UserModel) app.add_routes([web.view('/index', _Index, name='index')]) return app
async def setup_routes(app): app.add_routes([ web.get('/', index), web.view('/api/1.0/vehicles', ApiVehiclesView), web.get('/api/1.0/vehicles/{id}', get_instance), web.put('/api/1.0/vehicles/{id}', edit), web.delete('/api/1.0/vehicles/{id}', delete) ])
def add_routes(app: web.Application) -> None: """ Route adding/resolving for resources and views""" _add_static_routes( app ) # add static routes first so that they will be at top of table and retrieved first app.add_routes([ web.view("/", views.IndexView), ])
def _register_ingress(self) -> None: """Register Ingress functions.""" api_ingress = APIIngress() api_ingress.coresys = self.coresys self.webapp.add_routes([ web.post('/ingress/session', api_ingress.create_session), web.view('/ingress/{token}/{path:.*}', api_ingress.handler), ])
async def setup_routes(app, handler): h = handler client = h.client p = r"/{chat:[^/]+}" routes = [ web.get('/', h.home), web.post('/otg', h.dynamic_view), web.get('/otg', h.otg_view), web.get('/pc', h.playlist_creator), web.get(p, h.index), web.get(p + r"/logo", h.logo), web.get(p + r"/{id:\d+}/view", h.info), web.get(p + r"/{id:\d+}/download", h.download_get), web.head(p + r"/{id:\d+}/download", h.download_head), web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get), #below routes work without alias id web.get(r"/{id:\d+}/view", h.info), web.get(r"/{id:\d+}/download", h.download_get), web.head(r"/{id:\d+}/download", h.download_head), web.view(r'/{wildcard:.*}', h.wildcard) ] index_all = index_settings['index_all'] index_private = index_settings['index_private'] index_group = index_settings['index_group'] index_channel = index_settings['index_channel'] exclude_chats = index_settings['exclude_chats'] include_chats = index_settings['include_chats'] if index_all: async for chat in client.iter_dialogs(): alias_id = None if chat.id in exclude_chats: continue if chat.is_user: if index_private: alias_id = generate_alias_id(chat) elif chat.is_channel: if index_channel: alias_id = generate_alias_id(chat) else: if index_group: alias_id = generate_alias_id(chat) if not alias_id: continue log.debug( f"Index added for {chat.id} :: {chat.title} at /{alias_id}") else: for chat_id in include_chats: chat = await client.get_entity(chat_id) alias_id = generate_alias_id(chat) log.debug( f"Index added for {chat.id} :: {chat.title} at /{alias_id}") app.add_routes(routes)
def setup_routes(app, static=False): routes = [web.view(FED_DATASELECT_PATH_QUERY, DataselectView)] if static: path_static = pathlib.Path(__file__).parent / FED_STATIC append_static_routes( app, routes, FED_DATASELECT_PATH_MINISEED, path_static ) app.add_routes(routes)
def setup_routes(app: web.Application) -> None: app.add_routes([web.view('/connect/authorize', AuthorizeView), web.view('/connect/token', TokenView), web.view('/client', ClientListView), web.view('/client/register', RegisterClientView), web.view('/account', AccountListView), web.view('/account/create', CreateAccountView), web.view('/account/{username}', GetAccountView), web.route('*', '/{tail:.*}', catch_all)]) project_root = pathlib.Path(__file__).parent.parent app.add_routes([web.static('/static/', path=project_root / 'static', name='static')])