Текущий код:
Код: Выделить всё
@app.get("/Orderid")
def read_data(id: str = None,
token: str = Depends(oauth2_scheme)):
try:
user = fake_decode_token(token)
if not user:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail= "Invalid authentication credentials",
headers={"WWW-Authenticate": "Bearer"},
)
if id:
filtered_df = sale[sale["Order ID"].str.contains(id, case=False)]
return filtered_df.to_dict(orient='records')
else:
return sale.to_dict(orient='records')
except Exception as e:
return {"error" : str(e)}
Код: Выделить всё
@app.get("/Orderid")
def read_data(id: str = None,
date: str = None,
token: str = Depends(oauth2_scheme)):
try:
user = fake_decode_token(token)
if not user:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail= "Invalid authentication credentials",
headers={"WWW-Authenticate": "Bearer"},
)
if id and date:
filtered_df = (sale[sale["Order ID"].str.contains(id, case=False)] and sale[sale["Order Date"].str.contains(id, case=False)])
return filtered_df.to_dict(orient='records')
else:
return sale.to_dict(orient='records')
except Exception as e:
return {"error" : str(e)}
https://excelbanalytics.com/wp/wp-conte ... ecords.zip
Подробнее здесь: https://stackoverflow.com/questions/785 ... on-fastapi