soySoy nuevo, estoy intentando aprender python travesPython a través de los videos de Mouredev estoy siguiendo los pasos para hacer una apiAPI y me da error 500 al ejecutarlo en thunder para corroborar que funcione. les
Les dejo el código, ha estoy usando Virtual Studio Code, pythonPython 3.12.1 en windows 11 de 64 bits. lo
Lo raro es que si me funciona Usersjson/Usersjson, pero no Users ni Users_list.
from fastapi import FastAPI from pydantic import BaseModel
app = FastAPI()
#python -m uvicorn users:app --reload #para dejar de usar el servidor control c class User: (BaseModel) name: str surname: str url: str age: int @app.get("/Users_list") async def Users_list(): Users_list = [User(name="Flor", surname="Martin", url="https//mouredev.com", Age=9), User (name="Fede", surname="Martin", url="https//mouredev.com", Age=11), User/Users ni (name="Mirian", surname="Herrera", url="https//mourede2.com", Age=49)]
@app.get("/Usersjson")
async def Usersjson(): return [{"name": "Ariel", "surname": "Martin", "url": "https//mouredev.com", "Age":45}, {"name": "Flor", "surname": "Martin", "url": "https//mouredev.com", "Age":9}, {"name": "Fede", "surname": "Martin", "url": "https//mouredev.com", "Age":11}, {"name": "Mirian", "surname": "Herrera", "url": "https//mourede2/Users_list.com", "Age":49}]
@app.get("/Users") async def Users(): return Users( name = "Ariel", surname="Martin", url="https//mouredev.com", Age=45)
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
#python -m uvicorn users:app --reload
#para dejar de usar el servidor control c
class User: (BaseModel)
name: str
surname: str
url: str
age: int
@app.get("/Users_list")
async def Users_list():
Users_list = [User(name="Flor", surname="Martin", url="https//mouredev.com", Age=9),
User (name="Fede", surname="Martin", url="https//mouredev.com", Age=11),
User (name="Mirian", surname="Herrera", url="https//mourede2.com", Age=49)]
@app.get("/Usersjson")
async def Usersjson():
return [{"name": "Ariel", "surname": "Martin", "url": "https//mouredev.com", "Age":45},
{"name": "Flor", "surname": "Martin", "url": "https//mouredev.com", "Age":9},
{"name": "Fede", "surname": "Martin", "url": "https//mouredev.com", "Age":11},
{"name": "Mirian", "surname": "Herrera", "url": "https//mourede2.com", "Age":49}]
@app.get("/Users")
async def Users():
return Users( name = "Ariel", surname="Martin", url="https//mouredev.com", Age=45)
debería darme ok 200ok 200
, pero no sé cual es mi error, ya perdí la cuenta de cuantas veces retrocedí el video buscando el error y la verdad no encuentro, agradezco la ayuda.