Kurulum Adımları
1. FastAPI ve Uvicorn'u kurun:
pip install fastapi uvicorn[standard]2. Basit API oluşturun (main.py):
python
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
@app.get("/")
def root():
return {"message": "Merhaba Dunya!"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
@app.post("/items/")
def create_item(item: Item):
return item3. Sunucuyu başlatın:
uvicorn main:app --reload --host 0.0.0.0 --port 80004. API dokümantasyonuna erişin:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
5. Async endpoint:
python
@app.get("/async-test")
async def async_endpoint():
return {"result": "async calisiyor"}6. Production deployment:
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4İlgili Rehberler
Python Kurulumu ve pip
Python programlama dilini ve pip paket yöneticisini kurun.
Jupyter Notebook Kurulumu
Jupyter Notebook'u kurun ve interaktif Python geliştirme ortamını kullanın.
TensorFlow Kurulumu
Google TensorFlow makine öğrenimi kütüphanesini kurun ve ilk modelinizi oluşturun.
PyTorch Kurulumu
Meta PyTorch derin öğrenme kütüphanesini kurun ve temel kullanımını öğrenin.