Skip to content

Commit 887115f

Browse files
committed
# .mount()不要在分路由APIRouter().mount()调用,模板会报错
1 parent 56299d2 commit 887115f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# __author__ = '__Jack__'
44

55
import time
6-
76
import uvicorn
87
from fastapi import FastAPI, Request
98
from fastapi.middleware.cors import CORSMiddleware
9+
from fastapi.staticfiles import StaticFiles
1010

1111
from coronavirus import application
1212
from tutorial import app03, app04, app05, app06, app07, app08
@@ -23,6 +23,9 @@
2323
redoc_url='/redocs',
2424
)
2525

26+
# mount表示将某个目录下一个完全独立的应用挂载过来,这个不会在API交互文档中显示
27+
app.mount('/static', StaticFiles(directory='./coronavirus/static'), name='static') # .mount()不要在分路由APIRouter().mount()调用,模板会报错
28+
2629

2730
# @app.exception_handler(StarletteHTTPException) # 重写HTTPException异常处理器
2831
# async def http_exception_handler(request, exc):

0 commit comments

Comments
 (0)