|
| 1 | +from flask import Flask, render_template |
| 2 | + |
| 3 | +app = Flask(__name__) |
| 4 | + |
| 5 | +import random |
| 6 | + |
| 7 | +colors = ["Red", "Blue", "Green", "Pink", "Salmon", "Brown"] |
| 8 | +weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] |
| 9 | +months = ["January", "Feburary", "March", "April", "May", "June", "July", "August", "September", "November", "December"] |
| 10 | +cars = ["A Pinto", "A Yugo", "A Bug", "A Lambo", "A Ferrari"] |
| 11 | + |
| 12 | +@app.route("/") |
| 13 | +def home(): |
| 14 | + return render_template('index.html', heading="What's lucky for you?") |
| 15 | + |
| 16 | +@app.route("/cars") |
| 17 | +def cheap_cars(): |
| 18 | + car = random.choice(cars) |
| 19 | + return render_template('page.html', category='car', lucky_item=car,icon="car.png", heading="What's your lucky car?") |
| 20 | + |
| 21 | +@app.route("/color") |
| 22 | +def color_page(): |
| 23 | + color = random.choice(colors) |
| 24 | + return render_template('page.html', category='color', lucky_item=color, icon="paint.png") |
| 25 | + |
| 26 | +@app.route("/number") |
| 27 | +def number_page(): |
| 28 | + num = random.randint(1, 100) |
| 29 | + return render_template('page.html', category='number', lucky_item=num, icon="number.png") |
| 30 | + |
| 31 | +@app.route("/week") |
| 32 | +def week_page(): |
| 33 | + weekday = random.choice(weekdays) |
| 34 | + return render_template('page.html', category='weekday', lucky_item=weekday, icon="calendar.png") |
| 35 | + |
| 36 | +@app.route("/month") |
| 37 | +def month_page(): |
| 38 | + month = random.choice(months) |
| 39 | + return render_template('page.html', category='month', lucky_item=month, icon="calendar.png") |
0 commit comments