geovisualisierung/projects/project-3/backend/routers/accidents.py

37 lines
751 B
Python
Raw Normal View History

2020-12-20 01:36:36 +01:00
import logging
from typing import List
from fastapi import APIRouter
from pydantic.main import BaseModel
import api_database
router = APIRouter(prefix="/accidents", tags=["accidents", "local"])
LOG = logging.getLogger()
class Accident(BaseModel):
lat: float
lon: float
severity: str
@router.get(
"/",
name="Get all accidents",
description="Get all bike accidents in London.",
response_model=List[Accident]
)
def get_accidents():
return api_database.get_all_accidents()
@router.get(
"/{year}",
name="Get accidents by year",
description="Get bike accidents in London for a specific year.",
response_model=List[Accident]
)
def get_accidents(year: str):
return api_database.get_accidents(year)