|
|
@@ -0,0 +1,31 @@
|
|
|
+# 全局变量
|
|
|
+# 之后丢到env去
|
|
|
+PORT = 3002
|
|
|
+
|
|
|
+# 日志配置
|
|
|
+import logging
|
|
|
+logging.basicConfig(
|
|
|
+ level=logging.INFO,
|
|
|
+ format="\n[%(asctime)s - {%(module)s.py (%(lineno)d)} - %(funcName)s()]\n %(message)s\n",
|
|
|
+ datefmt="%Y-%m-%d,%H:%M:%S",
|
|
|
+)
|
|
|
+
|
|
|
+# 引入FastAPI
|
|
|
+from fastapi import FastAPI
|
|
|
+app = FastAPI()
|
|
|
+
|
|
|
+# 处理跨域
|
|
|
+from fastapi.middleware.cors import CORSMiddleware
|
|
|
+app.add_middleware(
|
|
|
+ CORSMiddleware,
|
|
|
+ allow_origins=["*"],
|
|
|
+ allow_methods=["*"],
|
|
|
+ allow_headers=["*"],
|
|
|
+ allow_credentials=True,
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ import uvicorn
|
|
|
+ uvicorn.run(app, host="0.0.0.0", port=PORT, workers=1)
|