Skip to content

Commit

Permalink
chore(api.py): set port via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpomerenke committed May 16, 2024
1 parent aa3ecf7 commit b04945c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend-python/media_impact_monitor/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Response,
TrendSearch,
)
from media_impact_monitor.util.env import PORT

git_commit = (os.getenv("VCS_REF") or "")[:7]
build_date = (os.getenv("BUILD_DATE") or "WIP").replace("T", " ")
Expand Down Expand Up @@ -116,4 +117,4 @@ def _get_impact(q: ImpactSearch) -> Response[ImpactSearch, Impact]:
if __name__ == "__main__":
import uvicorn

uvicorn.run(app)
uvicorn.run(app, port=PORT)
3 changes: 3 additions & 0 deletions backend-python/media_impact_monitor/util/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

load_dotenv()

PORT = int(environ.get("PORT", 8000))

ACLED_EMAIL = environ["ACLED_EMAIL"]
ACLED_KEY = environ["ACLED_KEY"]
MEDIACLOUD_API_TOKEN = environ["MEDIACLOUD_API_TOKEN"]
ZENROWS_API_KEY = environ["ZENROWS_API_KEY"]

assert PORT
assert ACLED_EMAIL
assert ACLED_KEY
assert MEDIACLOUD_API_TOKEN
Expand Down

0 comments on commit b04945c

Please sign in to comment.