Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, jsonify
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Home route
|
| 7 |
+
@app.route('/')
|
| 8 |
+
def home():
|
| 9 |
+
return render_template('index.html')
|
| 10 |
+
|
| 11 |
+
# API example
|
| 12 |
+
@app.route('/api/hello', methods=['GET'])
|
| 13 |
+
def hello():
|
| 14 |
+
name = request.args.get('name', 'World')
|
| 15 |
+
return jsonify({'message': f'Hello {name}!'})
|
| 16 |
+
|
| 17 |
+
# For Hugging Face Spaces
|
| 18 |
+
if __name__ == '__main__':
|
| 19 |
+
app.run(debug=True, host='0.0.0.0', port=7860)
|