Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move uvicorn port config to env file #1135

Open
eniiku opened this issue Feb 28, 2025 · 0 comments
Open

chore: move uvicorn port config to env file #1135

eniiku opened this issue Feb 28, 2025 · 0 comments

Comments

@eniiku
Copy link
Contributor

eniiku commented Feb 28, 2025

Description

The Uvicorn server port is currently hardcoded in main.py:

if __name__ == "__main__":
    uvicorn.run("main:app", port=7001, reload=True)

This configuration should be moved to an environment file (e.g., .env) to make it more flexible and configurable.


Proposed Changes

  1. Add a PORT variable to the .env file (update env.sample as well:
  PORT=7001
  1. Load the PORT variable from the environment in the Settings class (api/utils/settings.py):
  class Settings(BaseSettings):
  PORT: int = 7001  # Default value if not set in .env
  1. Update main.py to read the port from the environment file:
  from api.utils.settings import settings

  if __name__ == "__main__":
  uvicorn.run("main:app", port=settings.PORT, reload=True)

Acceptance Criteria:

  • The PORT variable is defined in the .env file.
  • The main.py file reads the port from the environment.
  • The application runs successfully using the port specified in the .env file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant