-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (24 loc) · 888 Bytes
/
app.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
"""
Flask will look for the folders called "templates" and "static" in the root folder of the project automatically.
You can change the name of the folders Flask looks for by doing:
app = Flask(__name__, template_folder="other_templates", static_folder="other_static")
"""
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# importing module
from routes import all_routes
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///database.db"
db = SQLAlchemy(app)
# Model for database
class Example(db.Model):
example_id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), nullable=False)
def __repr__(self):
return f"<Example {self.name}>"
with app.app_context():
db.create_all()
# Passing app above to all_routes function in routes.py module
all_routes(app)
if __name__ == "__main__":
app.run()