update
This commit is contained in:
@@ -14,12 +14,13 @@ app = FastAPI()
|
|||||||
# 允许所有来源跨域访问(不推荐用于生产环境)
|
# 允许所有来源跨域访问(不推荐用于生产环境)
|
||||||
origins = ["*"]
|
origins = ["*"]
|
||||||
|
|
||||||
|
# 设置CORS(跨域资源共享)策略
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=origins,
|
allow_origins=["*"], # 允许所有来源
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"], # 允许所有HTTP方法
|
allow_methods=["*"], # 允许所有方法
|
||||||
allow_headers=["*"], # 允许所有HTTP头
|
allow_headers=["*"], # 允许所有请求头
|
||||||
)
|
)
|
||||||
# 依赖注入
|
# 依赖注入
|
||||||
def get_db():
|
def get_db():
|
||||||
|
|||||||
4
run.py
4
run.py
@@ -1,4 +1,6 @@
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
# uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
||||||
|
uvicorn.run("app.main:app", host="127.0.0.1", port=8700, reload=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user