Skip to content

Commit

Permalink
refactor: Changed main.py
Browse files Browse the repository at this point in the history
Added src to pythonpath, change main function to use app.run()
  • Loading branch information
mike-pisman committed Oct 2, 2023
1 parent 3513d97 commit 8b76639
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import subprocess
from src.unipoll_api.__version__ import version
from src.unipoll_api.utils import colored_dbg
from unipoll_api.utils import cli_args


def run(host="127.0.0.1", port=8000, reload=None):
colored_dbg.info("University Polling API v{}".format(version))
try:
uvicorn_args: list[str] = ["--host", host, "--port", str(port)]
if reload:
uvicorn_args.append("--reload")
subprocess.run(["uvicorn", "unipoll_api.app:app"] + uvicorn_args, cwd="src")
except KeyboardInterrupt:
colored_dbg.info("University Polling API stopped")
import sys
sys.path.append("src")
from unipoll_api import app # noqa: E402


if __name__ == "__main__":
args = cli_args.parse_args()
run(args.host, args.port, args.reload)
app.run()

0 comments on commit 8b76639

Please sign in to comment.