1
|
from fastapi import FastAPI
|
2
|
import fastapi
|
3
|
from pydantic import BaseModel
|
4
|
from typing import Optional, List
|
5
|
|
6
|
app = FastAPI()
|
7
|
|
8
|
class Device(BaseModel):
|
9
|
vendor_id: int
|
10
|
product_id: int
|
11
|
serial_number: str
|
12
|
|
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.post("/api/v1/devices/")
|
26
|
async def root_dev_post(device: Device):
|
27
|
print(device)
|
28
|
return {"message": "Sucess"}
|
29
|
|
30
|
@app.get("/")
|
31
|
async def root_read():
|
32
|
print("Hello")
|
33
|
return {"message":"Hello World"}
|