-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (27 loc) · 830 Bytes
/
Copy pathapp.py
File metadata and controls
39 lines (27 loc) · 830 Bytes
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
33
34
35
36
37
38
import json
from flask import Flask, render_template
import requests
app = Flask(__name__)
@app.route('/')
def helloWorld():
return render_template("index.html")
@app.route('/hello/')
@app.route('/hello/<name>')
def helloName(name=None):
return render_template("hello.html", name=name)
#Read parks.json file and store it as parks
with open('parks.json', 'r') as f:
parks = json.load(f)
'''
@app.route('/parks')
def parksPage():
return render_template("parks.html", parks = parks)
'''
@app.route('/parks')
def nationalParksPage():
base_url = 'https://developer.nps.gov/api/v1/parks?api_key=oqa2UTZlkEAwogH10IBj7Rt687267NUWoSqoNQLC&limit=10'
r = requests.get(base_url)
parks = r.json()['data']
return render_template("parks.html", parks = parks)
if __name__ == "__main__":
app.run()