Download Flask.app from Pezh/Login: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/Pezh/Login/resolve/main/Flask.app
- Command line
-
hf download hf://spaces/Pezh/Login/Flask.app
-
curl -L -o Flask.app https://huggingface.co/spaces/Pezh/Login/resolve/main/Flask.app
1.05 kB
| from flask import Flask, render_template, request, jsonify | |
| app = Flask(__name__) | |
| # This will hold the items to be displayed as checkboxes. | |
| list_of_items = ['Item 1', 'Item 2', 'Item 3'] | |
| # This will hold the items that are checked. | |
| checked_items = [] | |
| def index(): | |
| return render_template('index.html') | |
| def multiply_by_2(): | |
| # Get the number from the input. | |
| number = request.form.get('number') | |
| result = '' | |
| if number: | |
| try: | |
| result = str(int(number) * 2) | |
| except ValueError: | |
| result = 'Invalid input' | |
| # Return the result to the frontend. | |
| return jsonify({'result': result}) | |
| def make_to_checkbox(): | |
| global checked_items | |
| # Get the list of checked items from the form. | |
| checked_items = request.form.getlist('items') | |
| # Return something to acknowledge the operation was handled. | |
| return jsonify({'status': 'success'}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) |