Skip to content
Discussion options

You must be logged in to vote

You should move models to separate module and import it to your main module

models.py

from fastapi import Cookie, Header, Form, status,  Path, Query, Body, Response
from sqlmodel import Field, Relationship,  SQLModel

class TeamBase(SQLModel):
    name: str = Field(index=True)
    headquarters: str

class Team(TeamBase, table=True):
    id: int | None = Field(default=None, primary_key=True)

bla.py

import uvicorn
from fastapi import FastAPI

from models import Team


app = FastAPI()
@app.get("/")
def root():
    return {"hello worldd": 42}


if __name__ == "__main__":
    uvicorn.run("bla:app", host="0.0.0.0", port=8000, reload=True)

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants