Spaces:
Sleeping
Sleeping
Commit ·
eea1d90
1
Parent(s): e8f6a78
fixed main.py
Browse files- app/main.py +16 -23
app/main.py
CHANGED
|
@@ -1,34 +1,27 @@
|
|
| 1 |
from fastapi import FastAPI, UploadFile, File
|
| 2 |
-
from fastapi.
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
from app.reliability_engine import compute_metrics
|
| 6 |
|
| 7 |
-
app
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
)
|
| 12 |
|
| 13 |
-
|
| 14 |
@app.get("/")
|
| 15 |
def root():
|
| 16 |
-
return {
|
| 17 |
-
"service": "RTL Reliability Engine",
|
| 18 |
-
"status": "running"
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
|
| 22 |
@app.post("/analyze")
|
| 23 |
-
async def
|
| 24 |
|
| 25 |
-
|
| 26 |
-
text = content.decode("utf-8")
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
return JSONResponse({
|
| 33 |
-
"analysis": metrics
|
| 34 |
-
})
|
|
|
|
| 1 |
from fastapi import FastAPI, UploadFile, File
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
import pandas as pd
|
| 4 |
|
| 5 |
+
app = FastAPI(title="RTL Reliability Engine")
|
|
|
|
| 6 |
|
| 7 |
+
app.add_middleware(
|
| 8 |
+
CORSMiddleware,
|
| 9 |
+
allow_origins=["*"],
|
| 10 |
+
allow_credentials=True,
|
| 11 |
+
allow_methods=["*"],
|
| 12 |
+
allow_headers=["*"],
|
| 13 |
)
|
| 14 |
|
|
|
|
| 15 |
@app.get("/")
|
| 16 |
def root():
|
| 17 |
+
return {"status": "running"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
@app.post("/analyze")
|
| 20 |
+
async def analyze(file: UploadFile = File(...)):
|
| 21 |
|
| 22 |
+
df = pd.read_csv(file.file)
|
|
|
|
| 23 |
|
| 24 |
+
return {
|
| 25 |
+
"rows": len(df),
|
| 26 |
+
"columns": list(df.columns)
|
| 27 |
+
}
|
|
|
|
|
|
|
|
|