abhinavvvvv commited on
Commit
eea1d90
·
1 Parent(s): e8f6a78

fixed main.py

Browse files
Files changed (1) hide show
  1. app/main.py +16 -23
app/main.py CHANGED
@@ -1,34 +1,27 @@
1
  from fastapi import FastAPI, UploadFile, File
2
- from fastapi.responses import JSONResponse
 
3
 
4
- from app.parser import parse_log_file
5
- from app.reliability_engine import compute_metrics
6
 
7
- app = FastAPI(
8
- title="RTL Reliability Engine",
9
- description="Analyze RTL simulation logs and compute reliability metrics",
10
- version="1.0"
 
 
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 analyze_logs(file: UploadFile = File(...)):
24
 
25
- content = await file.read()
26
- text = content.decode("utf-8")
27
 
28
- df = parse_log_file(text)
29
-
30
- metrics = compute_metrics(df)
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
+ }