-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp12.py
More file actions
32 lines (18 loc) · 649 Bytes
/
app12.py
File metadata and controls
32 lines (18 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#python 3.9.12
#python -m uvicorn app12:app --reload
from fastapi import FastAPI, File, UploadFile, Request
from proses import *
from fastapi.templating import Jinja2Templates
app = FastAPI()
templates = Jinja2Templates(directory="Template")
@app.get("/")
def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.get('/hello')
async def hello_world():
return "Flower Classification"
@app.post("/prediksi")
async def predict_image(file: UploadFile = File(...)):
conf, label = proses(file)
hasil = label + " ("+str(f"{conf*100:.2f}") + "%)"
return {"Text":hasil}