Browse Source

打包测试

Caner 2 years ago
parent
commit
b3c0802f1c
4 changed files with 33 additions and 3 deletions
  1. 0 1
      .gitignore
  2. 10 2
      README.md
  3. BIN
      dist/main
  4. 23 0
      main.py

+ 0 - 1
.gitignore

@@ -12,7 +12,6 @@ __pycache__/
 env/
 env/
 build/
 build/
 develop-eggs/
 develop-eggs/
-dist/
 downloads/
 downloads/
 eggs/
 eggs/
 .eggs/
 .eggs/

+ 10 - 2
README.md

@@ -1,3 +1,11 @@
-# python-uvicorn-fastApi
+# 闲鱼
+```
+154.12.31.11
+root:Vivo7788
 
 
-python http 服务demo
+```
+
+### 打包
+```
+pyinstaller --onefile --hidden-import main main.py
+```

BIN
dist/main


+ 23 - 0
main.py

@@ -0,0 +1,23 @@
+from fastapi import FastAPI
+from pydantic import BaseModel
+import uvicorn
+import logging
+
+
+# 服务
+app = FastAPI()
+
+# 参数声明
+class Item(BaseModel):
+    desc: str
+
+# 请求
+@app.post("/")
+def create_item(item:Item):
+    logging.info(item.desc)
+    return {"data": "true"}
+
+
+if __name__ == "__main__":
+    logging.basicConfig(filename='data.log', level=logging.INFO,format='%(asctime)s - %(levelname)s: %(message)s')
+    uvicorn.run("main:app",host="0.0.0.0", port=6688)