Skip to content

Commit 76b530f

Browse files
committed
Start some FastAPI examples
1 parent 158e4b7 commit 76b530f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

web/fastapi/hello_world/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Dependencies
2+
3+
You will need all of the following dependencies to run this example:
4+
5+
- Python virtual environment
6+
7+
## Python Virtual Environment
8+
9+
- Move to the fast-api folder
10+
- `cd <web/fastapi/hello_world>`
11+
- Create a virtual environment
12+
- On Mac: `python3 -m venv .venv`
13+
- On Windows: `python -m venv .venv`
14+
- Activate the virtual environment
15+
- On Mac: `source .venv/bin/activate`
16+
- On Windows: `.venv\Scripts\activate`
17+
- Install dependencies
18+
- On Mac: `pip3 install -r requirements.txt`
19+
- On Windows: `pip install -r requirements.txt`
20+
- Call a specific script
21+
- On Mac: `python3 <script_name>.py`
22+
- On Windows: `python <script_name>.py`
23+
- Deactivate virtual environment
24+
- `deactivate`
25+
26+
# Run the code
27+
Mac ` ./.venv/bin/fastapi dev main.py`

web/fastapi/hello_world/main.py

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

0 commit comments

Comments
 (0)