Skip to content

Commit

Permalink
feat(api): start command
Browse files Browse the repository at this point in the history
  • Loading branch information
eksno committed Sep 14, 2024
1 parent e569291 commit de64728
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ repository = "https://github.com/startino"
documentation = "https://starti.no/docs"
license = "BSL-1.1 (https://github.com/startino/relevantino/blob/alpha/LICENSE)"

[tool.poetry.scripts]
start = "src.__init__:run" # Assuming you have a main function in __init__.py

[tool.poetry.dependencies]
python = ">=3.11,<3.13"
uvicorn = "^0.27.1"
Expand Down
27 changes: 27 additions & 0 deletions services/api/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import logging
import os
import uvicorn
from dotenv import load_dotenv

from fastapi import FastAPI
Expand All @@ -23,3 +26,27 @@
@app.get("/")
def redirect_to_docts():
return RedirectResponse(url="/docs")


def run():
# app = create_app()
# sandbox_app = sandbox.create_app()
# app.mount("/sandbox", sandbox_app)

try:
PORT = os.environ.get("PORT")
if not PORT:
logging.info(
"PORT not found in environment variables. Using default PORT=8000"
)
PORT = 8000

PORT = int(PORT)
except Exception:
raise ValueError("PORT is not an integer")

uvicorn.run(app, host="0.0.0.0", port=PORT, log_config="logging.yaml")


if __name__ == "__main__":
run()

0 comments on commit de64728

Please sign in to comment.