-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76ac737
commit ed215ed
Showing
15 changed files
with
702 additions
and
659 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,32 @@ | ||
from __future__ import annotations | ||
|
||
import uvicorn | ||
from fastapi import FastAPI | ||
import logging | ||
from fastapi import FastAPI, HTTPException | ||
|
||
from API import route | ||
|
||
# Initialize logger | ||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
Fastapp = FastAPI() | ||
|
||
# API Router | ||
Fastapp.include_router(route.router) | ||
|
||
|
||
@Fastapp.get("/") | ||
def read_root(): | ||
return {"Hello": "FASTAPI"} | ||
|
||
try: | ||
return {"Hello": "FASTAPI"} | ||
except Exception as e: | ||
logger.error(f"Error in root endpoint: {e}") | ||
raise HTTPException(status_code=500, detail="Internal Server Error") | ||
|
||
# function to run server of FastAPI | ||
# Function to run FastAPI server | ||
def run_fastapi_app(): | ||
uvicorn.run(Fastapp, host="127.0.0.1", port=8000) | ||
try: | ||
uvicorn.run(Fastapp, host="127.0.0.1", port=8000) | ||
except Exception as e: | ||
logger.error(f"Error starting FastAPI server: {e}") | ||
raise |
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
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
Oops, something went wrong.