-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.py
executable file
·43 lines (35 loc) · 1.19 KB
/
script.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
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
from flask import Flask, send_file, url_for, render_template
from datetime import datetime
app = Flask(__name__)
dogs = ['Doberman', 'Golden Retriever', 'Snoop', 'Beagle', 'Bull Terrier',\
'Akita', 'Siberian Husky', 'Pit Bull', 'Pug', 'Black Lab']
@app.route('/')
def index():
"""
Returns
"""
img_url = url_for('static', filename='x.gif')
now = datetime.now()
return render_template('index.html',\
time=now,\
img_url=img_url)
@app.route('/user/<username>')
def render_username(username):
"""
Returns a specified page at the url /user/<username>
"""
img_url = url_for('static', filename='hal.jpg')
return render_template('user.html',\
username=username,\
img_url=img_url)
# TODO: Add '/dogs/' endpoint that returns random dog from list of dogs.
@app.route('/dogs/')
def render_dogs_page():
"""
Returns random dog from 'dogs' array above.
"""
### PUT DOGS ENDPOINT CODE HERE
pass # Remove this line when you write your own code
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True)