-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (29 loc) · 861 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, jsonify
import json
import os
app = Flask(__name__)
@app.route('/names', methods=['GET'])
def names():
obj = 'data/names.json'
if not os.path.exists(obj):
return jsonify({"error": "File not found"}), 404
with open(obj, 'r') as f:
data = json.load(f)
return jsonify(data), 200
@app.route('/fizz', methods=['GET'])
def fizz():
obj = 'data/fizz.json'
if not os.path.exists(obj):
return jsonify({"error": "File not found"}), 404
with open(obj, 'r') as f:
data = json.load(f)
return jsonify(data), 200
@app.route('/buzz', methods=['GET'])
def buzz():
obj = 'data/fizz.json'
if not os.path.exists(obj):
return jsonify({"error": "File not found"}), 404
with open(obj, 'r') as f:
data = json.load(f)
key = data[1][3]
return jsonify(key), 200