"""Routes for all endpoints in the API.""" from fastapi import APIRouter from repost.api.routes import users, auth, resubs, posts, comments api_router = APIRouter() api_router.include_router(auth.router, prefix='/auth', tags=['auth']) api_router.include_router(users.router, prefix='/users', tags=['users']) api_router.include_router(resubs.router, prefix='/resubs', tags=['resubs']) api_router.include_router(posts.router, prefix='/posts', tags=['posts']) api_router.include_router(comments.router, prefix='/comments', tags=['comments'])
if host_uuid is None: return session = create_session(cluster_id, get_xen_clusters=Settings.get_xen_clusters()) try: host = Host.get_by_uuid(session, host_uuid) except Failure as xenapi_error: if xenapi_error.details[0] == "UUID_INVALID": raise HTTPException(status_code=404, detail=f"Host {host_uuid} does not exist") raise HTTPException(status_code=500, detail=xenapi_failure_jsonify(xenapi_error)) except Fault as xml_rpc_error: raise HTTPException( status_code=int(xml_rpc_error.faultCode), detail=xml_rpc_error.faultString, ) session.xenapi.session.logout() # === Router Actions === host_router = APIRouter(dependencies=[Depends(verify_host_uuid)]) host_router.include_router(_host_list, tags=["host"]) host_router.include_router(_host_info, tags=["host"])
from fastapi import APIRouter from .auth import router as auth_router from .system import router as host_router router = APIRouter() router.include_router(auth_router, prefix='/auth') router.include_router(host_router, prefix='/system')
from fastapi import APIRouter from project.items.api import router as item_router from project.user.api import router as user_router root_api_router = APIRouter() root_api_router.include_router(user_router, tags=["User"]) root_api_router.include_router(item_router, prefix='/item', tags=["Items"])
from fastapi import APIRouter from .endpoints import user router = APIRouter() router.include_router(user.router, prefix="/user", tags=["Users"])
from fastapi import APIRouter from ._root import _root_router from .nstreme_dual import nstreme_dual_router from .access_list import access_list_router from .registration_table import registration_table_router wireless_router = APIRouter() wireless_router.include_router(_root_router, prefix="") wireless_router.include_router(nstreme_dual_router, prefix="/nstreme-dual") wireless_router.include_router(access_list_router, prefix="/access-list") wireless_router.include_router(registration_table_router, prefix="/registration-table")
from fastapi import APIRouter from core.controllers import accounts router = APIRouter() router.include_router(accounts.router, prefix='/accounts', tags=accounts.tags)
def build_router() -> APIRouter: router = APIRouter() router.include_router(person.router) return router
def get_b_a_path_override(): return "Hello B A" @router_b_a_c_override.get("/") def get_b_a_c(): return "Hello B A C" @router_b_a_c_override.get("/override", response_class=OverrideResponse) def get_b_a_c_path_override(): return {"msg": "Hello B A C"} router_b_a.include_router(router_b_a_c_override, prefix="/c", default_response_class=HTMLResponse) router_b_override.include_router(router_b_a, prefix="/a") router_a.include_router(router_a_a, prefix="/a") router_a.include_router(router_a_b_override, prefix="/b", default_response_class=PlainTextResponse) app.include_router(router_a, prefix="/a") app.include_router(router_b_override, prefix="/b", default_response_class=PlainTextResponse) client = TestClient(app) orjson_type = "application/x-orjson" text_type = "text/plain; charset=utf-8"
from fastapi import APIRouter from . import events about_router = APIRouter(prefix="/api/about") about_router.include_router(events.router)
from fastapi import APIRouter from app.core.casbin_auth import CasbinRoute from . import ungrouped router = APIRouter() router.route_class = CasbinRoute router.include_router( ungrouped.router, prefix="/ungrouped", tags=['ungrouped'])
# --- # разделение приложения на модульные кусочки делается с помощью роутера # --- from fastapi import APIRouter from .operations import router as operations_router from .auth import router as auth_router from .reports import router as reports_router # корневой роутер (к нему подключаются остальные роутеры приложения) router = APIRouter() # подключение роутеров к корневому роутеру router.include_router(auth_router) router.include_router(operations_router) router.include_router(reports_router)
""" request handlers """ from fastapi import APIRouter from . import admin from . import commands from . import scripting from . import users from . import world router = APIRouter() router.include_router(world.router) router.include_router(scripting.router) router.include_router(admin.router) router.include_router(commands.router) router.include_router(users.router)
from fastapi import APIRouter from app.api.routes.cleanings import router as cleanings_router router = APIRouter() router.include_router(cleanings_router, prefix="/cleanings", tags=["cleanings"])
from fastapi import APIRouter from api.endpoints import data api_router = APIRouter() api_router.include_router(data.router, prefix="/data", tags=["data"])
from fastapi import APIRouter from app.api.v1 import test_api api_router = APIRouter() api_router.include_router(test_api.router)
if console_uuid is None: return session = create_session(cluster_id, get_xen_clusters=Settings.get_xen_clusters()) try: console = Console.get_by_uuid(session, console_uuid) except Failure as xenapi_error: if xenapi_error.details[0] == "UUID_INVALID": raise HTTPException( status_code=404, detail=f"Console {console_uuid} does not exist") raise HTTPException(status_code=500, detail=xenapi_failure_jsonify(xenapi_error)) except Fault as xml_rpc_error: raise HTTPException( status_code=int(xml_rpc_error.faultCode), detail=xml_rpc_error.faultString, ) session.xenapi.session.logout() # === Router Actions === console_router = APIRouter(dependencies=[Depends(verify_console_uuid)]) console_router.include_router(_console_info, tags=["console"])
from fastapi import APIRouter import youwol.backends.assets.root_paths as assets import youwol.backends.assets_gateway.root_paths as assets_gateway import youwol.backends.cdn.root_paths as cdn import youwol.backends.cdn_apps_server.root_paths as cdn_apps_server import youwol.backends.cdn_sessions_storage.root_paths as cdn_sessions_storage import youwol.backends.flux.root_paths as flux import youwol.backends.stories.root_paths as stories import youwol.backends.treedb.root_paths as treedb router = APIRouter() cached_headers = None router.include_router(cdn_apps_server.router, prefix="/applications", tags=["cdn applications server"]) router.include_router(cdn.router, prefix="/api/cdn-backend", tags=["cdn"]) router.include_router(treedb.router, prefix="/api/treedb-backend", tags=["treedb"]) router.include_router(assets.router, prefix="/api/assets-backend", tags=["assets"]) router.include_router(flux.router, prefix="/api/flux-backend", tags=["flux"]) router.include_router(stories.router, prefix="/api/stories-backend", tags=["stories"]) router.include_router(assets_gateway.router, prefix="/api/assets-gateway", tags=["assets-gateway"])
from fastapi import APIRouter from cerebro.api.master_node import router as master_node_router router = APIRouter() router.include_router(master_node_router)
from fastapi import APIRouter from app.api.routes import authentication, comments, profiles, tags, users from app.api.routes.articles import api as articles router = APIRouter() router.include_router(authentication.router, tags=["authentication"], prefix="/users") router.include_router(users.router, tags=["users"], prefix="/user") router.include_router(profiles.router, tags=["profiles"], prefix="/profiles") router.include_router(articles.router, tags=["articles"]) router.include_router( comments.router, tags=["comments"], prefix="/articles/{slug}/comments", ) router.include_router(tags.router, tags=["tags"], prefix="/tags")
from fastapi import APIRouter from app.api_v1.endpoints import (sra, biosample, geo) api_router = APIRouter() api_router.include_router(sra.router, prefix='/sra', tags=['SRA']) api_router.include_router(biosample.router, prefix='/biosample', tags=['Biosample']) #api_router.include_router(geo.router, prefix='/geo', tags=['GEO'])
from messenger import messenger from fastapi import APIRouter routes = APIRouter() routes.include_router(messenger.router, prefix="messenger/")
from fastapi import APIRouter from app.api.api_v1.endpoints import users, login api_router = APIRouter() api_router.include_router(login.router, tags=["login"]) api_router.include_router(users.router, prefix="/users", tags=["users"])
from fastapi import APIRouter from views import accounts api_router = APIRouter() api_router.include_router(accounts.router, tags=["login"])
from fastapi import APIRouter from app.routers.v1.endpoints import home, login, users, events api_router = APIRouter() api_router.include_router(home.router, tags=['home']) api_router.include_router(login.router, tags=["login"]) api_router.include_router(users.router, prefix="/users", tags=["users"]) api_router.include_router(events.router, prefix="/events", tags=["events"])
from fastapi import APIRouter, Depends from app.deliveries import ( item_controller, user_controller, product_controller, product_category_controller, product_detail_controller, product_insurance_type_controller, ) from app.middlewares import auth api = APIRouter() api.include_router( user_controller.router, tags=["users"]) api.include_router( item_controller.router, tags=["items"], dependencies=[Depends(auth.get_current_active_user)], responses={404: {"description": "Not found"}}, ) api.include_router( product_controller.router, tags=["products"], responses={404: {"description": "Not found"}}, ) api.include_router( product_category_controller.router, tags=["product_categories"],
# %% ---------------------- """ yaml文件读取 """ if ~os.path.isdir(path_api_yml): path_api_yml = Path(__file__).parents[1] / "conf" / path_api_yml api_config = get_yaml_data(path_api_yml) # todo:加入logging中 fastapi_logger.info("\n"+str(print_api_config(api_config))) # %% ------------------------ """ 动态加载库以及注册服务 """ api_router = APIRouter() for kind in ["services", "tasks"]: for api_name, api_info in api_config.get(kind, {}).items(): if api_name is not None: # 动态加载 api_func = importlib.import_module(name="app.api.hub." + kind + "." + api_info.get("path", api_name)) # 注册服务 api_router.include_router(api_func.router, prefix="/" + api_info["prefix"], tags=[api_info["tags"]]) # %% ------------------- """ 单文件可debug """
''' Description: Version: 1.0 Autor: Moyu Date: 2020-11-23 11:37:56 LastEditors: Moyu LastEditTime: 2020-11-25 15:52:47 ''' from fastapi import APIRouter from fastapi.responses import ORJSONResponse from .v1 import sys_user from .v1 import sys_menu api_router = APIRouter(default=ORJSONResponse) api_router.include_router(sys_user.router, tags=["系统用户"], prefix='/base') api_router.include_router(sys_menu.router, tags=["系统菜单"], prefix='/menu')
from fastapi import APIRouter from controller import authentication from controller import category from controller import tourist_spot from controller import me router = APIRouter() router.include_router(authentication.router) router.include_router(category.router) router.include_router(tourist_spot.router) router.include_router(me.router)
from copy import deepcopy from starlette.requests import Request from fastapi import APIRouter from starlette.responses import JSONResponse from projectionist.amis.base import PAGE as amis_base from projectionist.libs.template import templates from projectionist.models.admin import AdminPage from projectionist.views.admin import channel router = APIRouter() router.include_router(channel.router, prefix="/channel") @router.get("/") async def admin_index(request: Request): from projectionist.amis.index import PAGE amis_page = {} amis_page.update(amis_base) amis_page.update(PAGE) items = await AdminPage.get_list() amis_data = {"items": items} print('admin') return templates.TemplateResponse("base.html", { "request": request, "amis_page": amis_page, "amis_data": amis_data, })