39 lines
810 B
Python
39 lines
810 B
Python
from fastapi import FastAPI, Header, Path
|
|
from pydantic import BaseModel
|
|
from typing import List
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class MetricResponse(BaseModel):
|
|
data: List = [1, 2, 3]
|
|
metrics: str
|
|
|
|
|
|
@app.get("/metrics/{metric}", response_model=MetricResponse)
|
|
def get_metrics(
|
|
metric: str = Path(
|
|
...,
|
|
title='Metric',
|
|
description='The metric needed. Must be one of "bets", "deposits" or '
|
|
'"registrations"',
|
|
regex=r'^(bets$)|(deposits$)|(registrations$)',
|
|
),
|
|
earliest: str = Header(None, title='Earliest time',),
|
|
):
|
|
var = MetricResponse(metrics='s')
|
|
return {'metric': 's'}
|
|
|
|
|
|
class Item(BaseModel):
|
|
name: str
|
|
description: str = None
|
|
price: float
|
|
tax: float = None
|
|
|
|
|
|
@app.post("/items/")
|
|
async def create_item(item: Item):
|
|
return item
|