-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathh22_web_app_01_app.py
More file actions
39 lines (30 loc) · 1.33 KB
/
h22_web_app_01_app.py
File metadata and controls
39 lines (30 loc) · 1.33 KB
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
from flask import Flask, render_template
app = Flask(__name__)
import random
colors = ["Red", "Blue", "Green", "Pink", "Salmon", "Brown"]
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
months = ["January", "Feburary", "March", "April", "May", "June", "July", "August", "September", "November", "December"]
cars = ["Pinto", "Yugo", "Bug", "Lambo", "Ferrari"]
@app.route("/")
def home():
return render_template('index.html', heading="What's lucky for you?")
@app.route("/cars")
def cheap_cars():
car = random.choice(cars)
return render_template('page.html', category='car', lucky_item=car,icon="car.png", heading="What's your lucky car?")
@app.route("/color")
def color_page():
color = random.choice(colors)
return render_template('page.html', category='color', lucky_item=color, icon="paint.png")
@app.route("/number")
def number_page():
num = random.randint(1, 100)
return render_template('page.html', category='number', lucky_item=num, icon="number.png")
@app.route("/week")
def week_page():
weekday = random.choice(weekdays)
return render_template('page.html', category='weekday', lucky_item=weekday, icon="calendar.png")
@app.route("/month")
def month_page():
month = random.choice(months)
return render_template('page.html', category='month', lucky_item=month, icon="calendar.png")