diff --git a/.gitignore b/.gitignore index ed8ebf5..6d17870 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -__pycache__ \ No newline at end of file +__pycache__ +.env \ No newline at end of file diff --git a/example_dot.env b/example_dot.env new file mode 100644 index 0000000..ebbd51f --- /dev/null +++ b/example_dot.env @@ -0,0 +1 @@ +APP_PORT=5000 \ No newline at end of file diff --git a/main.py b/main.py index f5844c3..765dc84 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,17 @@ from fastapi import FastAPI +from pydantic_settings import BaseSettings, SettingsConfigDict from routes import sso import uvicorn +class Settings(BaseSettings): + port: int = 5000 + + model_config = SettingsConfigDict(env_file=".env", extra="ignore") + +settings = Settings() + app = FastAPI() app.include_router(sso.router, prefix="/api/v2/sso") if __name__ == '__main__': - uvicorn.run(app, host="0.0.0.0", port=5000) \ No newline at end of file + uvicorn.run(app, host="0.0.0.0", port=settings.port) \ No newline at end of file