-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added src to pythonpath, change main function to use app.run()
- Loading branch information
1 parent
3513d97
commit 8b76639
Showing
1 changed file
with
4 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |