forked from feliciahsieh/AirBnB_clone_v3
-
Notifications
You must be signed in to change notification settings - Fork 65
/
1-hbnb.py
executable file
·32 lines (26 loc) · 919 Bytes
/
1-hbnb.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
#!/usr/bin/python3
"""Flask app to generate complete html page containing location/amenity
dropdown menus and rental listings"""
from flask import Flask, render_template
from models import storage
import uuid
app = Flask('web_dynamic')
app.url_map.strict_slashes = False
@app.route('/1-hbnb')
def display_hbnb():
"""Generate page with popdown menu of states/cities"""
states = storage.all('State')
amenities = storage.all('Amenity')
places = storage.all('Place')
cache_id = uuid.uuid4()
return render_template('1-hbnb.html',
states=states,
amenities=amenities,
places=places,
cache_id=cache_id)
@app.teardown_appcontext
def teardown_db(*args, **kwargs):
"""Close database or file storage"""
storage.close()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)