Explorar el Código

fastapi structure

tanlie hace 5 horas
padre
commit
f142d2a717

+ 24 - 0
FastApi/.gitignore

@@ -0,0 +1,24 @@
+.venv/
+__pycache__/
+*.py[cod]
+*.pyo
+*.pyd
+.pytest_cache/
+.mypy_cache/
+.ruff_cache/
+.coverage
+.coverage.*
+htmlcov/
+*.egg-info/
+dist/
+build/
+# Keep .env.example tracked; ignore only real environment files.
+.env
+.env.local
+.env.*
+!.env.example
+.idea/
+.vscode/
+.DS_Store
+Thumbs.db
+logs/

+ 14 - 0
FastApi/app/__init__.py

@@ -0,0 +1,14 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import FastAPI
+
+from app.mobile import register_mobile_routes
+
+
+def create_app():
+    app = FastAPI()
+    register_mobile_routes(app)
+    return app

+ 5 - 0
FastApi/app/admim/__init__.py

@@ -0,0 +1,5 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""

+ 12 - 0
FastApi/app/mobile/__init__.py

@@ -0,0 +1,12 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""
+
+
+def register_mobile_routes(app):
+    from app.mobile.views import user, wish, chat, tree, upload, admin_user
+    routers = [user, wish, chat, tree, upload, admin_user]
+    for router in routers:
+        app.include_router(router)

+ 13 - 0
FastApi/app/mobile/views/__init__.py

@@ -0,0 +1,13 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""
+__all__ = ["user", "wish", "chat", "tree", "upload", "admin_user"]
+
+from app.mobile.views.admin_user_views import admin_user
+from app.mobile.views.chat_views import chat
+from app.mobile.views.file_upload_views import upload
+from app.mobile.views.tree_views import tree
+from app.mobile.views.user_views import user
+from app.mobile.views.wish_views import wish

+ 8 - 0
FastApi/app/mobile/views/admin_user_views.py

@@ -0,0 +1,8 @@
+"""
+admin_user -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+admin_user = APIRouter(prefix="/admin", tags=["admin"])

+ 8 - 0
FastApi/app/mobile/views/chat_views.py

@@ -0,0 +1,8 @@
+"""
+chat -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+chat = APIRouter(prefix="/dgapi/mobile/chat", tags=["mobile chat"])

+ 8 - 0
FastApi/app/mobile/views/file_upload_views.py

@@ -0,0 +1,8 @@
+"""
+file_upload -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+upload = APIRouter(prefix="/dgapi/mobile/upload", tags=["mobile upload"])

+ 8 - 0
FastApi/app/mobile/views/tree_views.py

@@ -0,0 +1,8 @@
+"""
+tree -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+tree = APIRouter(prefix="/dgapi/mobile/tree", tags=["mobile tree"])

+ 28 - 0
FastApi/app/mobile/views/user_views.py

@@ -0,0 +1,28 @@
+"""
+user - mobile user views
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+user = APIRouter(prefix="/dgapi/mobile/user", tags=["mobile user"])
+
+
+@user.get("/login/captcha", summary="获取验证码")
+def get_captcha():
+    return {"message": "get captcha"}
+
+
+@user.post("/login", summary="登录")
+def login():
+    return {"message": "login"}
+
+
+@user.post("/logout", summary="登出")
+def logout():
+    return {"message": "logout"}
+
+
+@user.get("/wish-summary", summary="心愿单摘要")
+def wish_summary():
+    return "心愿单"

+ 8 - 0
FastApi/app/mobile/views/wish_views.py

@@ -0,0 +1,8 @@
+"""
+wish -
+auther: tanlie
+date: 2026/8/30
+"""
+from fastapi import APIRouter
+
+wish = APIRouter(prefix="/dgapi/mobile/wish", tags=["mobile wish"])

+ 5 - 0
FastApi/app/models/__init__.py

@@ -0,0 +1,5 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""

+ 5 - 0
FastApi/app/upms/__init__.py

@@ -0,0 +1,5 @@
+"""
+__init__.py -
+auther: tanlie
+date: 2026/8/30
+"""

+ 14 - 0
FastApi/main.py

@@ -0,0 +1,14 @@
+"""
+wishing you a happy life
+python version api for wishing tree
+author: tanlie
+date: 2026/8/30
+"""
+from app import create_app
+
+app = create_app()
+
+if __name__ == "__main__":
+    import uvicorn
+
+    uvicorn.run("main:app", host="0.0.0.0", port=8000)

+ 7 - 0
FastApi/test/test_main.http

@@ -0,0 +1,7 @@
+# Test your FastAPI endpoints
+
+
+GET http://127.0.0.1:8000/dgapi/mobile/user/login/captcha
+Accept: application/json
+
+###