diff --git a/main.py b/main.py index 2e7ab90..8bc378b 100644 --- a/main.py +++ b/main.py @@ -70,9 +70,9 @@ async def read_item(test_id: int): return {"test_string": result} -@app.put("/test/add") -async def add_item(test_string: str): - if test_string != "": +@app.post("/test/add") +async def add_item(test_string: Union[str, None] = None): + if test_string: with engine.connect() as conn: trans = conn.begin() insert = test.insert().values(testString=test_string) @@ -81,9 +81,11 @@ async def add_item(test_string: str): rows = conn.execute(select(test)) for row in rows: print(row) + msg = {"message": "Item added"} else: raise HTTPException(status_code=404, detail="Item not found") - return None + msg = {"message": "err"} + return msg with engine.connect() as conn: