venv script grabber added
This commit is contained in:
parent
6de9a56f86
commit
6a64ee2155
17
app.py
17
app.py
@ -1,11 +1,22 @@
|
||||
from fastapi import FastAPI, Request, HTTPException
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
import json
|
||||
from grabber import Grabber
|
||||
|
||||
app = FastAPI()
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
ordi1 = Grabber()
|
||||
|
||||
@app.get("/ordi1", response_class=HTMLResponse)
|
||||
async def read_item(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
request=request, name="ordi.html", context={"ordi": ordi1}
|
||||
)
|
||||
|
||||
@app.post("/endpoint")
|
||||
async def receive_info(request: Request):
|
||||
# Lire le body brut
|
||||
@ -27,8 +38,4 @@ async def receive_info(request: Request):
|
||||
print(f"Hostname is {ordi1.hostname}")
|
||||
print(f"Motherboard serial is {ordi1.mb_serial}")
|
||||
|
||||
return {"status": "ok"}
|
||||
|
||||
@app.get("/ordi1")
|
||||
async def get_ordi1_info():
|
||||
return ordi1
|
||||
return {"status": "ok"}
|
||||
@ -365,6 +365,7 @@ python_venv() {
|
||||
source gbvenv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
uvicorn app:app --reload --host 0.0.0.0 --port 8000
|
||||
}
|
||||
|
||||
# Making the summary
|
||||
|
||||
Reference in New Issue
Block a user