Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1278,5 +1278,28 @@ with gr.Blocks(css=CUSTOM_CSS, title="OmniParse AI Enterprise") as demo:
|
|
| 1278 |
gr_register_btn.click(fn=gr_register_with_tos, inputs=[gr_auth_user, gr_auth_pass], outputs=[gr_auth_response])
|
| 1279 |
gr_checkout_btn.click(fn=gr_checkout, inputs=[gr_auth_user], outputs=[gr_checkout_out])
|
| 1280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1281 |
if __name__ == "__main__":
|
| 1282 |
-
|
|
|
|
| 1278 |
gr_register_btn.click(fn=gr_register_with_tos, inputs=[gr_auth_user, gr_auth_pass], outputs=[gr_auth_response])
|
| 1279 |
gr_checkout_btn.click(fn=gr_checkout, inputs=[gr_auth_user], outputs=[gr_checkout_out])
|
| 1280 |
|
| 1281 |
+
# ─── FASTAPI + STRIPE WEBHOOK ────────────────────────────────────────────────
|
| 1282 |
+
from fastapi import FastAPI, Request, Response
|
| 1283 |
+
import uvicorn
|
| 1284 |
+
|
| 1285 |
+
app_api = FastAPI()
|
| 1286 |
+
|
| 1287 |
+
@app_api.post("/webhook")
|
| 1288 |
+
async def stripe_webhook(request: Request):
|
| 1289 |
+
payload = await request.body()
|
| 1290 |
+
sig_header = request.headers.get("stripe-signature", "")
|
| 1291 |
+
result = handle_stripe_webhook(payload, sig_header)
|
| 1292 |
+
data = json.loads(result)
|
| 1293 |
+
status_code = 200 if data.get("status") == "OK" else 400
|
| 1294 |
+
return Response(content=result, status_code=status_code, media_type="application/json")
|
| 1295 |
+
|
| 1296 |
+
@app_api.get("/health")
|
| 1297 |
+
async def health():
|
| 1298 |
+
return {"status": "ok", "model_loaded": MODEL_LOADED}
|
| 1299 |
+
|
| 1300 |
+
# Mount Gradio into FastAPI
|
| 1301 |
+
import gradio as gr
|
| 1302 |
+
app_api = gr.mount_gradio_app(app_api, demo, path="/")
|
| 1303 |
+
|
| 1304 |
if __name__ == "__main__":
|
| 1305 |
+
uvicorn.run(app_api, host="0.0.0.0", port=7860)
|