1 |
d446b62c
|
matejzeman
|
from fastapi import FastAPI
|
2 |
|
|
import fastapi
|
3 |
|
|
from pydantic import BaseModel
|
4 |
|
|
from typing import Optional, List
|
5 |
54840605
|
matejzeman
|
|
6 |
|
|
app = FastAPI()
|
7 |
|
|
|
8 |
d446b62c
|
matejzeman
|
class Device(BaseModel):
|
9 |
|
|
vendor_id: int
|
10 |
|
|
product_id: int
|
11 |
becb7eb1
|
matejzeman
|
serial_number: str
|
12 |
d446b62c
|
matejzeman
|
|
13 |
|
|
class USBLog(BaseModel):
|
14 |
|
|
username: str
|
15 |
|
|
hostname: str
|
16 |
|
|
timestamp: str
|
17 |
|
|
device: Device
|
18 |
|
|
status:str
|
19 |
|
|
|
20 |
|
|
@app.post("/api/v1/usb-logs/")
|
21 |
|
|
async def root_post(usb_log: USBLog):
|
22 |
|
|
print(usb_log)
|
23 |
|
|
return {"message": "Sucess"}
|
24 |
|
|
|
25 |
|
|
@app.get("/")
|
26 |
|
|
async def root_read():
|
27 |
|
|
print("Hello")
|
28 |
|
|
return {"message":"Hello World"}
|