hassoudi commited on
Commit
c43f30f
·
verified ·
1 Parent(s): 75c8918

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -96,3 +96,25 @@ def register_user(request: RegisterRequest, x_api_key: str = Depends(token_heade
96
  API_KEYS[new_key] = {"usage_count": 0, "label": request.label}
97
  save_keys()
98
  return {"message": "User registered", "api_key": new_key}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  API_KEYS[new_key] = {"usage_count": 0, "label": request.label}
97
  save_keys()
98
  return {"message": "User registered", "api_key": new_key}
99
+
100
+
101
+ @app.get("/list_users")
102
+ def list_users(x_api_key: str = Depends(token_header)):
103
+ if x_api_key != ADMIN_KEY:
104
+ raise HTTPException(status_code=403, detail="Admin access required")
105
+ return {"users": API_KEYS}
106
+
107
+ @app.get("/", include_in_schema=False)
108
+ def root():
109
+ return HTMLResponse("""
110
+ <html>
111
+ <head><title>MagBERT-NER API</title></head>
112
+ <body style="font-family:sans-serif;">
113
+ <h1>✅ MagBERT-NER API is running!</h1>
114
+ <p>This is a private FastAPI app.</p>
115
+ <p>Visit <a href="/docs">/docs</a> to explore the API interface.</p>
116
+ </body>
117
+ </html>
118
+ """)
119
+
120
+