Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,25 @@ from flask import Flask, request
|
|
| 2 |
from flask_cors import CORS
|
| 3 |
import sample_rust
|
| 4 |
import os
|
| 5 |
-
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
app = Flask(__name__)
|
| 8 |
CORS(app) # Allow CORS for all routes
|
| 9 |
|
| 10 |
@app.route("/process", methods=["POST"])
|
| 11 |
def process():
|
| 12 |
name = request.form.get("name", "World")
|
|
|
|
| 13 |
result = sample_rust.hello(name)
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from flask_cors import CORS
|
| 3 |
import sample_rust
|
| 4 |
import os
|
| 5 |
+
import logging
|
| 6 |
|
| 7 |
+
# Enable debug logs
|
| 8 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 9 |
+
|
| 10 |
+
# Setup Flask app
|
| 11 |
app = Flask(__name__)
|
| 12 |
CORS(app) # Allow CORS for all routes
|
| 13 |
|
| 14 |
@app.route("/process", methods=["POST"])
|
| 15 |
def process():
|
| 16 |
name = request.form.get("name", "World")
|
| 17 |
+
logging.debug(f"Received name: {name}")
|
| 18 |
result = sample_rust.hello(name)
|
| 19 |
+
logging.debug(f"Rust response: {result}")
|
| 20 |
+
return result
|
| 21 |
+
|
| 22 |
+
# Main runner
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
port = int(os.environ.get("PORT", 7860)) # Hugging Face uses 7860
|
| 25 |
+
logging.info(f"🚀 Starting server on port {port}")
|
| 26 |
+
app.run(host="0.0.0.0", port=port)
|