|
Size: 814
Comment:
|
Size: 1504
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 6: | Line 6: |
| FastAPI works OK without uv. You can build, install, and run FastAPI projects using traditional tools like pip, venv, and poetry | |
| Line 10: | Line 11: |
| {{{ | {{{#!highlight sh |
| Line 20: | Line 21: |
pip install fastapi[standard] # Virtual Environment: Python's built-in venv module # Dependency Management: requirements.txt or pyproject.toml |
|
| Line 40: | Line 45: |
== pip , venv steps == {{{#!highlight sh python3 -m venv .venv source .venv/bin/activate echo "fastapi[standard]" > requirements.txt cat << 'EOF' > main.py from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"mensagem": "Olá, Mundo! Criado via terminal!"} EOF fastapi dev main.py # http://127.0.0.1:8000 uvicorn main:app --reload }}} |
FastAPI
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
FastAPI works OK without uv. You can build, install, and run FastAPI projects using traditional tools like pip, venv, and poetry
main.py
Install
1 # uv An extremely fast Python package and project manager, written in Rust.
2 # https://docs.astral.sh/uv/getting-started/installation/
3 curl -LsSf https://astral.sh/uv/install.sh | sh
4 pipx install uv
5 pip install uv
6 uv self update
7 pip install --upgrade uv
8
9 uv add "fastapi[standard]"
10
11 pip install fastapi[standard]
12 # Virtual Environment: Python's built-in venv module
13 # Dependency Management: requirements.txt or pyproject.toml
14
Run
uv run fastapi dev
pip , venv steps
1 python3 -m venv .venv
2 source .venv/bin/activate
3 echo "fastapi[standard]" > requirements.txt
4
5 cat << 'EOF' > main.py
6 from fastapi import FastAPI
7
8 app = FastAPI()
9
10 @app.get("/")
11 def read_root():
12 return {"mensagem": "Olá, Mundo! Criado via terminal!"}
13 EOF
14
15 fastapi dev main.py
16 # http://127.0.0.1:8000
17 uvicorn main:app --reload
