feat: create MVP database table, adjust api
This commit is contained in:
18
main.py
18
main.py
@@ -10,7 +10,6 @@ with open("db.secrets", "r") as f:
|
||||
|
||||
app = FastAPI(title="cutt")
|
||||
engine = create_engine(db_secrets)
|
||||
# SQLModel.metadata.create_all(engine)
|
||||
origins = [
|
||||
"*",
|
||||
"http://localhost",
|
||||
@@ -36,6 +35,23 @@ class Chemistry(SQLModel, table=True):
|
||||
undecided: list[str] = Field(sa_column=Column(ARRAY(String)))
|
||||
|
||||
|
||||
class MVPRanking(SQLModel, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
time: datetime | None = Field(default_factory=datetime.now)
|
||||
user: str
|
||||
mvps: list[str] = Field(sa_column=Column(ARRAY(String)))
|
||||
|
||||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
||||
@app.post("/mvps/", status_code=status.HTTP_200_OK)
|
||||
def submit_mvps(mvps: MVPRanking):
|
||||
with Session(engine) as session:
|
||||
session.add(mvps)
|
||||
session.commit()
|
||||
|
||||
|
||||
@app.post("/chemistry/", status_code=status.HTTP_200_OK)
|
||||
def submit_chemistry(chemistry: Chemistry):
|
||||
with Session(engine) as session:
|
||||
|
||||
Reference in New Issue
Block a user