def create_app(): fast_app = FastAPI(debug=True) register_tortoise(fast_app, config=TORTOISE_ORM) fast_app.mount('/admin', admin_app) admin_app.init( user_model='User', admin_secret='test', models='examples.models', site=Site( name='微服务管理后台', logo= 'https://github.com/long2ice/fastapi-admin/raw/master/front/static/img/logo.png', locale='zh-CN', locale_switcher=False, menu=[ Menu(name='首页', url='/', icon='fa fa-home'), Menu(name='配置', title=True), Menu(name='应用', url='/rest/App', icon='fa fa-pencil', sort_fields=('uaid', )), Menu(name='多对多测试', url='/rest/ManyToManyTest'), Menu(name='阿里云秘钥', url='/rest/AliYunSecret', icon='fa fa-user-secret'), Menu(name='阿里云OSS', url='/rest/AliYunOss', icon='fa fa-database'), Menu(name='App短信', url='/rest/AppSms', icon='fa fa-envelope-o', search_fields=('app', )), Menu(name='百度AI', url='/rest/BaiduAi', icon='fa fa-desktop'), Menu( name='App百度AI', url='/rest/AppBaiduAi', icon='fa fa-laptop', ), Menu(name='在线参数', url='/rest/Config', icon='fa fa-cog'), Menu(name='基本信息', title=True), Menu(name='请求日志', url='/rest/ApiLog', icon='fa fa-sticky-note'), Menu(name='App版本', url='/rest/AppVersion', icon='fa fa-mobile'), Menu(name='授权', title=True), Menu(name='用户', url='/rest/User', icon='fa fa-user'), Menu(name='注销', url='/login', icon='fa fa-lock') ])) fast_app.add_middleware( CORSMiddleware, allow_origins=['*'], allow_credentials=True, allow_methods=['*'], allow_headers=['*'], ) return fast_app
async def start_up(): admin_app.debug = False admin_app.init( user_model='User', tortoise_app='models', admin_secret='test', permission=True, site=Site( name='FastAPI-admin Demo', logo= 'https://github.com/long2ice/fastapi-admin/raw/master/front/static/img/logo.png', login_footer='FASTAPI ADMIN - FastAPI Admin Dashboard', login_description='FastAPI Admin Dashboard', locale='en-US', locale_switcher=True, theme_switcher=True, menus=[ Menu(name='Home', url='/', icon='fa fa-home'), Menu(name='Content', title=True), Menu(name='Product', url='/rest/Product', icon='icon-list', search_fields=('type', ), fields_type={ 'type': 'radiolist', 'image': 'link' }, bulk_actions=[{ 'value': 'delete', 'text': 'delete_all', }, { 'value': 'test_bulk', 'text': 'TestBulk' }], attrs={ 'name': { 'cols': 6 }, 'view_num': { 'cols': 3 }, 'sort': { 'cols': 3 }, 'created_at': { 'cols': 6 }, 'categories': { 'cols': 6 }, }), Menu(name='Category', url='/rest/Category', icon='icon-list'), Menu( name='Config', url='/rest/Config', icon='fa fa-pencil', ), Menu(name='External', title=True), Menu(name='Github', url='https://github.com/long2ice/fastapi-admin', icon='fa fa-github', external=True), Menu(name='Auth', title=True), Menu( name='User', url='/rest/User', icon='fa fa-user', exclude=('password', ), search_fields=('username', ), fields_type={'avatar': 'image'}, ), Menu(name='Role', url='/rest/Role', icon='fa fa-group', actions={'delete': False}), Menu(name='Permission', url='/rest/Permission', icon='fa fa-user-plus', actions={'delete': False}), Menu(name='Logout', url='/logout', icon='fa fa-lock', actions={'delete': False}) ]))
async def start_up(): await admin_app.init( # nosec admin_secret="test", permission=True, admin_log=True, site=Site( name="FastAPI-Admin DEMO", login_footer="FASweTAPI ADMIN - FastAPI Admin Dashboard", login_description="FastAPI Admin Dashboard", locale="en-US", locale_switcher=True, theme_switcher=True, menus=[ Menu(name="Home", url="/", icon="fa fa-home"), Menu( name="Content", children=[ Menu( name="Category", url="/rest/Category", icon="fa fa-list", search_fields=("slug", LikeFilter), ), Menu( name="Config", url="/rest/Config", icon="fa fa-gear", import_=True, search_fields=("key", ), custom_filters=[CustomFilter], ), Menu( name="Product", url="/rest/Product", icon="fa fa-table", search_fields=("name", ), ), ], ), Menu( name="External", children=[ Menu( name="Github", url="https://github.com/long2ice/fastapi-admin", icon="fa fa-github", external=True, ), ], ), Menu( name="Auth", children=[ Menu( name="User", url="/rest/User", icon="fa fa-user", search_fields=("username", ), ), Menu( name="Role", url="/rest/Role", icon="fa fa-group", ), Menu( name="Permission", url="/rest/Permission", icon="fa fa-user-plus", ), Menu( name="AdminLog", url="/rest/AdminLog", icon="fa fa-align-left", search_fields=("action", "admin", "model"), ), Menu( name="Logout", url="/logout", icon="fa fa-lock", ), ], ), ], ), )
def create_app(): fast_app = FastAPI(debug=True) register_tortoise(fast_app, config=TORTOISE_ORM, generate_schemas=True) fast_app.mount('/admin', admin_app) admin_app.debug = True admin_app.init( user_model='User', admin_secret='test', models='examples.models', permission=True, site=Site( name='FastAPI-admin Demo', logo= 'https://github.com/long2ice/fastapi-admin/raw/master/front/static/img/logo.png', locale='en-US', locale_switcher=True, menu=[ Menu(name='Home', url='/', icon='fa fa-home'), Menu(name='Content', title=True), Menu(name='Product', url='/rest/Product', icon='icon-list', search_fields=('type', ), fields_type={'type': 'radiolist'}, bulk_actions=[{ 'value': 'delete', 'text': 'delete_all', }, { 'value': 'test_bulk', 'text': 'TestBulk' }]), Menu(name='Category', url='/rest/Category', icon='icon-list'), Menu(name='External', title=True), Menu(name='Github', url='https://github.com/long2ice/fastapi-admin', icon='fa fa-github', external=True), Menu(name='Auth', title=True), Menu(name='User', url='/rest/User', icon='fa fa-user', exclude=('password', ), search_fields=('username', )), Menu(name='Role', url='/rest/Role', icon='fa fa-group'), Menu(name='Permission', url='/rest/Permission', icon='fa fa-user-plus'), Menu(name='Logout', url='/logout', icon='fa fa-lock') ])) fast_app.add_middleware( CORSMiddleware, allow_origins=['*'], allow_credentials=True, allow_methods=['*'], allow_headers=['*'], ) return fast_app