Skip to content

Commit 2b7ab2f

Browse files
committed
Basic fastapi setup
0 parents  commit 2b7ab2f

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# FastAPI - demo
2+
3+
Install FastAPI with all the optional dependencies and features:
4+
```sh
5+
pip install "fastapi[all]"
6+
```
7+
8+
Start `uvicorn` with:
9+
```sh
10+
uvicorn main:app --reload
11+
```
12+
13+
Access the API documentation at http://localhost:8000/docs

main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Union
2+
3+
from fastapi import FastAPI
4+
5+
app = FastAPI()
6+
7+
8+
@app.get("/")
9+
def read_root():
10+
return {"Hello": "World"}
11+
12+
13+
@app.get("/items/{item_id}")
14+
def read_item(item_id: int, q: Union[str, None] = None):
15+
return {"item_id": item_id, "q": q}

0 commit comments

Comments
 (0)