HF-docker3 / app.py
AntDX316
updated
c767c56
raw
history blame contribute delete
700 Bytes
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__)
# Store tasks in memory (would use a database in a real application)
tasks = []
@app.route('/')
def index():
return render_template('index.html', tasks=tasks)
@app.route('/add', methods=['POST'])
def add():
task = request.form.get('task')
if task:
tasks.append(task)
return redirect(url_for('index'))
@app.route('/delete/<int:task_id>')
def delete(task_id):
if 0 <= task_id < len(tasks):
tasks.pop(task_id)
return redirect(url_for('index'))
if __name__ == '__main__':
# Use port 7860 for Hugging Face Spaces
app.run(debug=True, host='0.0.0.0', port=7860)