-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (27 loc) · 950 Bytes
/
main.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
import random
from flask_sqlalchemy import SQLAlchemy
from flask import Flask, render_template
app = Flask(__name__)
app.config["SECRET_KEY"] = "secret_key"
# Creating the database.
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///pokemon.db"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Pokemon(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(300))
# abilities = db.Column(db.String(300), unique=True, nullable=False)
img_url = db.Column(db.String(300))
pokemons = []
for i in range(1,21):
pokemon = Pokemon.query.get(i)
pokemons.append(pokemon)
@app.route("/")
def home():
return render_template("index.html", pokemons=pokemons,number=len(pokemons))
@app.route("/widget")
def widget():
temp_poke = random.choice(pokemons)
return render_template("widget.html", pokemon=temp_poke)
if __name__ == "__main__":
app.run(debug=True)