extend /getdata endpoint with list view
This commit is contained in:
23
main.py
23
main.py
@@ -32,6 +32,29 @@ async def read_item(date: str, index: str = "DAX", show_all_indices: Optional[bo
|
||||
|
||||
|
||||
|
||||
@app.get("/getdata")
|
||||
async def get_indices_paginated(page: int = 1, page_size: int = 30):
|
||||
all_dates = list(fake_items_db.keys())
|
||||
total_pages = (len(all_dates) + page_size - 1) // page_size
|
||||
|
||||
start_index = (page - 1) * page_size
|
||||
end_index = start_index + page_size
|
||||
|
||||
current_page_dates = all_dates[start_index:end_index]
|
||||
|
||||
indices_data = []
|
||||
for date in current_page_dates:
|
||||
indices_data.append(fake_items_db[date])
|
||||
|
||||
return {
|
||||
"page": page,
|
||||
"total_pages": total_pages,
|
||||
"page_size": page_size,
|
||||
"data": indices_data
|
||||
}
|
||||
|
||||
|
||||
|
||||
@app.post("/uploadfile/")
|
||||
async def create_upload_files(file: UploadFile = File(...)):
|
||||
content = await file.read()
|
||||
|
||||
Reference in New Issue
Block a user