Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask, request, jsonify
|
| 3 |
+
from waitress import serve
|
| 4 |
+
|
| 5 |
+
app = Flask(__name__)
|
| 6 |
+
|
| 7 |
+
@app.get("/health")
|
| 8 |
+
def health():
|
| 9 |
+
return jsonify({"ok": True})
|
| 10 |
+
|
| 11 |
+
@app.post("/v1/echo")
|
| 12 |
+
def echo():
|
| 13 |
+
"""
|
| 14 |
+
JSON body:
|
| 15 |
+
{ "text": "hello" }
|
| 16 |
+
|
| 17 |
+
Returns:
|
| 18 |
+
{ "input": "...", "output": "..." }
|
| 19 |
+
"""
|
| 20 |
+
data = request.get_json(silent=True) or {}
|
| 21 |
+
text = data.get("text", "")
|
| 22 |
+
# Simple test behavior (replace later with Gemini call)
|
| 23 |
+
output = f"Andy heard: {text}"
|
| 24 |
+
return jsonify({"input": text, "output": output})
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
# HF Spaces expects your server to bind to 0.0.0.0 and the PORT env var if present.
|
| 28 |
+
port = int(os.environ.get("PORT", "7860"))
|
| 29 |
+
serve(app, host="0.0.0.0", port=port)
|