Spaces:
Sleeping

Login / ffl.py
Pezh's picture
Create ffl.py
4a69f59 verified
Raw History Blame Contribute Delete
699 Bytes
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
# This list will be modified when items are added via the 'send' button
list_1 = ['Item 1', 'Item 2', 'Item 3']
@app.route('/')
def index():
return render_template('index.html')
@app.route('/get_items', methods=['GET'])
def get_items():
# Return all items in list_1 as JSON
return jsonify(list_1)
@app.route('/add_item', methods=['POST'])
def add_item():
item = request.json['item']
if item: # Only add non-empty item
list_1.append(item)
return jsonify({'success': True, 'item': item})
return jsonify({'success': False})
if __name__ == '__main__':
app.run(debug=True)