Skip to content
Snippets Groups Projects

code updated for bike service

parent 5455293a
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,18 @@ class Bike(BaseModel):
last_maintenance_date: str
maintenance_history: str
class BikeResponse(BaseModel):
id: int
model: str
status: Optional[str]
location: str
condition: str
price_per_hour: float
last_maintenance_date: str
maintenance_history: str
# Routes
@app.post("/bikes/", response_model=Bike)
async def create_bike(bike: Bike):
......@@ -72,13 +84,14 @@ async def create_bike(bike: Bike):
@app.get("/bikes/", response_model=List[Bike])
@app.get("/bikes/", response_model=List[BikeResponse])
async def read_bikes():
cursor.execute('SELECT * FROM Bikes')
bikes = cursor.fetchall()
bike_objects = []
for bike in bikes:
bike_obj = Bike(
bike_obj = BikeResponse(
id=bike[0],
model=bike[1],
status=bike[2],
location=bike[3],
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment