Skip to content

Commit b93be98

Browse files
committed
Create template fastapi BE
1 parent 4778ced commit b93be98

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,25 @@ https://chatgpt.com/share/680cb4dd-78b0-8000-9039-0861c2b0e24c
7070

7171
## Local Setup steps
7272

73-
`pip install -e .[dev]`
73+
`pip install -e .[dev]`
74+
75+
## Running the FastAPI Application Locally
76+
77+
To run the FastAPI application locally, follow these steps:`
78+
79+
1. **Run the Application**:
80+
Navigate to the `src` directory and start the FastAPI application using:
81+
```bash
82+
uvicorn app:app --reload
83+
```
84+
85+
1. **Access the Application**:
86+
Open your browser and navigate to:
87+
```
88+
http://127.0.0.1:8000
89+
```
90+
91+
1. **API Documentation**:
92+
FastAPI provides interactive API documentation. You can access it at:
93+
- Swagger UI: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
94+
- ReDoc: [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc)

src/app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from fastapi import FastAPI
2+
3+
app = FastAPI()
4+
5+
@app.get("/hello")
6+
def hello_world():
7+
return {"message": "Hello, World!"}

tests/test_app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from fastapi.testclient import TestClient
2+
from src.app import app
3+
4+
client = TestClient(app)
5+
6+
def test_hello_world():
7+
response = client.get("/hello")
8+
assert response.status_code == 200
9+
assert response.json() == {"message": "Hello, World!"}

0 commit comments

Comments
 (0)