Initial Upload

This commit is contained in:
2024-02-28 20:08:16 +01:00
parent a08513190c
commit f2884e185e
7 changed files with 177 additions and 0 deletions

27
app.py Normal file
View File

@@ -0,0 +1,27 @@
from flask import Flask, request, jsonify, render_template
import json
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
#'Welcome to the Flask App'
@app.route('/saveNumber', methods=['POST'])
def save_number():
data = request.get_json()
number = request.form.get('numberInput')
if number is not None:
# Save number to JSON file
with open('data.json', 'w') as json_file:
json.dump({'number': number}, json_file)
return jsonify({'message': 'Number saved successfully'}), 200
else:
return jsonify({'error': 'Invalid data provided'}), 400
if __name__ == '__main__':
app.run(debug=True)