22 lines
532 B
Python
22 lines
532 B
Python
from typing import Union
|
|
|
|
import polars as pl
|
|
from fastapi import FastAPI, Response
|
|
|
|
import data
|
|
|
|
d = data.load()
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"Hello": "World"}
|
|
|
|
@app.get("/items/{item_id}")
|
|
def read_item(item_id: int):
|
|
ext = d.extractions_for(item_id).pl()
|
|
out = ext.with_columns(pl.col("calendar").str.extract_all(r"([0-9]{4}-[0-9]{2}-[0-9]{2})|[0-2]").alias("calendar_data"))
|
|
out = out.drop(['calendar', 'property_id'])
|
|
return Response(content=out.write_json(), media_type="application/json") |