File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ pip3 install -r requirements.txt
2222
2323# run project with uvicorn
2424uvicorn " fastapi_project.main:app" --reload --port=8000
25+
26+ # or, run bash with shell
27+ ./run_fastapi_project.sh
2528```
2629
2730# deploy on production
@@ -35,4 +38,11 @@ uvicorn "fastapi_project.main:app" --reload --port=8000
3538
3639set the environment variable
3740* ` DATABASE_URL `
38- * ` LOAD_SQL_PROJECT ` value will be ` yes `
41+ * ` LOAD_SQL_PROJECT ` value will be ` yes `
42+
43+ ## Project route
44+
45+ ``` bash
46+ http://localhost:8000/api/v1/users
47+ http://localhost:8000/health
48+ ```
Original file line number Diff line number Diff line change 1+ from fastapi import APIRouter , status
2+ from fastapi .responses import JSONResponse
3+
4+ # Create a api router
5+ router = APIRouter ()
6+
7+ # Health check route
8+ @router .get ("/" )
9+ async def health_check ():
10+ data = {"status" : "ok" }
11+ return JSONResponse (content = data , status_code = status .HTTP_200_OK )
Original file line number Diff line number Diff line change 22from fastapi import FastAPI
33from dotenv import load_dotenv
44from fastapi .middleware .cors import CORSMiddleware
5- from fastapi_project .api import root_index
5+ from fastapi_project .api import health , root_index
66
77# Load .env file
88load_dotenv ()
1414def create_application ():
1515 application = FastAPI ()
1616
17- # Include the root index router
17+ # Include the root index and health router
1818 application .include_router (root_index .router )
19+ application .include_router (health .router , prefix = "/health" )
1920
2021
2122 if load_sql_project == True :
2223 print ("SQL_PROJECT is enabled" )
2324 # Include additional routers if LOAD_SQL_PROJECT is enabled
2425 from fastapi_project .api .v1 import user
25- application .include_router (user .router )
26+ application .include_router (user .router , prefix = "/api/v1" )
2627
2728 # Add CORS middleware
2829 # In production, replace the "*" with the actual frontend URL
File renamed without changes.
You can’t perform that action at this time.
0 commit comments