mirror of
https://github.com/ferdzo/iotDashboard.git
synced 2026-04-05 09:06:26 +00:00
27 lines
599 B
Python
27 lines
599 B
Python
from fastapi import FastAPI
|
|
|
|
from cert_manager import CertificateManager
|
|
from models import DeviceRegistrationRequest, DeviceRegistrationResponse
|
|
|
|
app = FastAPI()
|
|
|
|
cert_manager = CertificateManager()
|
|
|
|
@app.get("/")
|
|
async def hello():
|
|
return {"Hello": "World"}
|
|
|
|
@app.post("/devices/register")
|
|
async def register_device(request: DeviceRegistrationRequest) -> DeviceRegistrationResponse:
|
|
"""
|
|
Register a new device and issue an X.509 certificate.
|
|
"""
|
|
response = cert_manager.register_device(
|
|
name=request.name,
|
|
location=request.location,
|
|
)
|
|
|
|
|
|
return response
|
|
|