|
|
@@ -67,7 +67,7 @@ async def root(): |
|
|
async def get_countries(): |
|
|
async def get_countries(): |
|
|
"""Get list of all available countries with their slugs""" |
|
|
"""Get list of all available countries with their slugs""" |
|
|
return { |
|
|
return { |
|
|
"countries": circuit_service.get_countries_list() |
|
|
|
|
|
|
|
|
"countries": [c.to_dict() for c in circuit_service.get_countries_list()] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@app.get("/circuits/{country_slug}") |
|
|
@app.get("/circuits/{country_slug}") |
|
|
@@ -76,7 +76,7 @@ async def get_cities(country_slug: str): |
|
|
cities = circuit_service.get_localities_list(country_slug) |
|
|
cities = circuit_service.get_localities_list(country_slug) |
|
|
if not cities: |
|
|
if not cities: |
|
|
raise HTTPException(status_code=404, detail="Country not found") |
|
|
raise HTTPException(status_code=404, detail="Country not found") |
|
|
return {"cities": cities} |
|
|
|
|
|
|
|
|
return {"cities": [c.to_dict() for c in cities]} |
|
|
|
|
|
|
|
|
@app.get("/circuits/{country_slug}/{city_slug}") |
|
|
@app.get("/circuits/{country_slug}/{city_slug}") |
|
|
async def get_circuits(country_slug: str, city_slug: str): |
|
|
async def get_circuits(country_slug: str, city_slug: str): |
|
|
@@ -84,7 +84,7 @@ async def get_circuits(country_slug: str, city_slug: str): |
|
|
circuits = circuit_service.get_circuits_list(country_slug, city_slug) |
|
|
circuits = circuit_service.get_circuits_list(country_slug, city_slug) |
|
|
if not circuits: |
|
|
if not circuits: |
|
|
raise HTTPException(status_code=404, detail="City not found") |
|
|
raise HTTPException(status_code=404, detail="City not found") |
|
|
return {"circuits": circuits} |
|
|
|
|
|
|
|
|
return {"circuits": [c.to_dict() for c in circuits]} |
|
|
|
|
|
|
|
|
@app.get("/circuits/{country_slug}/{city_slug}/{circuit_slug}") |
|
|
@app.get("/circuits/{country_slug}/{city_slug}/{circuit_slug}") |
|
|
async def get_circuit_details(country_slug: str, city_slug: str, circuit_slug: str): |
|
|
async def get_circuit_details(country_slug: str, city_slug: str, circuit_slug: str): |
|
|
@@ -92,7 +92,7 @@ async def get_circuit_details(country_slug: str, city_slug: str, circuit_slug: s |
|
|
circuit_details = circuit_service.get_circuit_details(country_slug, city_slug, circuit_slug) |
|
|
circuit_details = circuit_service.get_circuit_details(country_slug, city_slug, circuit_slug) |
|
|
if not circuit_details: |
|
|
if not circuit_details: |
|
|
raise HTTPException(status_code=404, detail="Circuit not found") |
|
|
raise HTTPException(status_code=404, detail="Circuit not found") |
|
|
return circuit_details |
|
|
|
|
|
|
|
|
return circuit_details.to_dict() |
|
|
|
|
|
|
|
|
@app.get("/circuits/{country_slug}/{city_slug}/{circuit_slug}/layout/{layout_slug}") |
|
|
@app.get("/circuits/{country_slug}/{city_slug}/{circuit_slug}/layout/{layout_slug}") |
|
|
async def get_layout_details(country_slug: str, city_slug: str, circuit_slug: str, layout_slug: str): |
|
|
async def get_layout_details(country_slug: str, city_slug: str, circuit_slug: str, layout_slug: str): |
|
|
@@ -100,7 +100,7 @@ async def get_layout_details(country_slug: str, city_slug: str, circuit_slug: st |
|
|
layout_details = circuit_service.get_layout_details(country_slug, city_slug, circuit_slug, layout_slug) |
|
|
layout_details = circuit_service.get_layout_details(country_slug, city_slug, circuit_slug, layout_slug) |
|
|
if not layout_details: |
|
|
if not layout_details: |
|
|
raise HTTPException(status_code=404, detail="Layout not found") |
|
|
raise HTTPException(status_code=404, detail="Layout not found") |
|
|
return layout_details |
|
|
|
|
|
|
|
|
return layout_details.to_dict() |
|
|
|
|
|
|
|
|
@app.get("/tracks/{country_slug}/{city_slug}/{circuit_slug}/year/{year}/{image_format}") |
|
|
@app.get("/tracks/{country_slug}/{city_slug}/{circuit_slug}/year/{year}/{image_format}") |
|
|
async def get_track_by_year( |
|
|
async def get_track_by_year( |
|
|
|