blob: 1c759e75d2057633b6f74d310e7ff439e6c99186 (
plain)
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
|
import click
from flask import Flask
from flask_bcrypt import Bcrypt
from flask.cli import AppGroup
from flask_sqlalchemy import SQLAlchemy
import flask_login
app = Flask(__name__)
app.config.from_object('app.config')
bcrypt = Bcrypt(app)
db = SQLAlchemy(app)
login_manager = flask_login.LoginManager()
login_manager.init_app(app)
from app.models import User
database_cli = AppGroup("database")
@database_cli.command("create")
def create_database():
db.create_all()
@database_cli.command("delete")
def delete_database():
db.drop_all()
app.cli.add_command(database_cli)
from app.views import main
@login_manager.user_loader
def load_user(email):
return User.query.filter(User.email == email).first()
|