Escribe para buscar…

REST

Un servidor web es pot configurar com un servidor de recursos que s'accedeixen mijançant un conjunt de funcions "externes" o endpoints (API)

Esta página todavía no se ha traducido — se muestra en su idioma original:Català

Entorn de treball

Crea un projecte amb uv

ps
uv init python-rest
cd python-rest

El primer pas és instal·lar FastAPI.

ps
uv add "fastapi[standard]"
Note

Quan instal·les amb uv add "fastapi[standard]" ve amb algunes dependències estàndard opcionals per defecte, incloent fastapi-cloud-cli, que et permet desplegar a FastAPI Cloud.

Si no vols tenir aquestes dependències opcionals, pots instal·lar en canvi uv add fastapi.

Si vols instal·lar les dependències estàndard però sense el fastapi-cloud-cli, pots instal·lar amb uv add "fastapi[standard-no-fastapi-cloud-cli]"

Primers passos

The app variable is the “instance” of the class FastAPI and will be the main point of interaction to create all your API.

python
main.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "Hello World"}

Estás leyendo una vista previa.

Inicia sesión para leer el artículo completo. Cualquier cuenta abre 4 artículos gratuitos al mes; el alumnado y el profesorado leen las páginas de su curso sin límite.

Iniciar sesión