Shinhati2023 commited on
Commit
fc70338
·
verified ·
1 Parent(s): b76a728

Create app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +21 -0
app/main.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File
2
+ from app.analyzer import analyze_code
3
+
4
+ app = FastAPI(title="Code Quality Gate API")
5
+
6
+ @app.post("/audit")
7
+ async def audit_code(file: UploadFile = File(...)):
8
+ content = await file.read()
9
+ code_text = content.decode("utf-8")
10
+
11
+ issues = analyze_code(code_text)
12
+
13
+ # Calculate a simple "Health Score"
14
+ score = max(100 - (len(issues) * 10), 0)
15
+
16
+ return {
17
+ "filename": file.filename,
18
+ "health_score": f"{score}/100",
19
+ "issues_found": len(issues),
20
+ "details": issues
21
+ }