BrickTracker/app.py

28 lines
697 B
Python
Raw Normal View History

2024-02-28 20:08:16 +01:00
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)