-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
22 lines (18 loc) · 740 Bytes
/
app.py
File metadata and controls
22 lines (18 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Flask, request, jsonify
import json
app = Flask(__name__)
# Load allowed dB levels from an external JSON file
def load_db_levels():
try:
with open('allowed_db_levels.json', 'r') as file:
return json.load(file)
except FileNotFoundError:
return {}
@app.route('/info', methods=['GET'])
def get_allowed_db():
allowed_db_levels = load_db_levels() # Load the dictionary from the JSON file
location = request.args.get('location', '').strip().lower() # Convert location to lowercase
allowed_db = allowed_db_levels.get(location, 150) # Fetch dB level
return jsonify({"allowed_dB": allowed_db})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)