tanlie ed1bb1cfb2 rename 1 месяц назад
..
app ed1bb1cfb2 rename 1 месяц назад
scripts abd926f038 test(db): add User model and DB test script (not containing secrets) 1 месяц назад
test f142d2a717 fastapi structure 1 месяц назад
.env.example abd926f038 test(db): add User model and DB test script (not containing secrets) 1 месяц назад
.gitignore f142d2a717 fastapi structure 1 месяц назад
README.md 582af97e46 chore: auto-load .env if python-dotenv present; document python-dotenv in README 1 месяц назад
main.py f890e33b4b fast api 视图函数接收请求参数的方法。 1 месяц назад

README.md

Wishing Tree — FastAPI service

Setup

Create a .env file (or set environment variables) with your database connection. Do NOT commit secrets.

Recommended (preferred): set a full SQLAlchemy DATABASE_URL environment variable with URL-encoded password.

Example (PowerShell):

$env:DATABASE_URL = "mysql+pymysql://root:%40%40qinys12346..@192.168.1.177:3306/wishing_tree?charset=utf8mb4&serverTimezone=Asia/Shanghai&use_unicode=true&characterEncoding=utf-8"

Or set components separately (Windows PowerShell):

$env:DB_USER = "root" $env:DB_PASS = "@@qinys12346.." $env:DB_HOST = "192.168.1.177" $env:DB_PORT = "3306" $env:DB_NAME = "wishing_tree"

Dependencies

Install runtime dependencies for database access:

pip install sqlalchemy pymysql

Optional: install python-dotenv to auto-load a .env file located at project root

pip install python-dotenv

Running

Start the app in development (example):

uvicorn main:app --reload --host 0.0.0.0 --port 8000

Notes

  • The project reads DATABASEURL if present; otherwise it composes a URL from DB* vars.
  • Passwords with special characters must be URL-encoded when used in DATABASE_URL.
  • Keep .env out of version control; use the provided .env.example as a template.