This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from . import main | |
@main.route(‘/’) | |
def index(): | |
return “Hello World!”, 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from app import create_app, db | |
app = create_app(os.getenv(‘FLASK_CONFIG’) or ‘default’) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
basedir = os.path.abspath(os.path.dirname(__file__)) | |
class Config: | |
SECRET_KEY = os.environ.get(‘SECRET_KEY’, ‘secret’) | |
STREAM_API_KEY = ‘’#Insert your Stream API key her | |
STREAM_SECRET = ‘’#Insert your Stream Secret here | |
@staticmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set FLASK_APP=application.py | |
flask run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pip install flask-wtf flask-login flask-mail flask-migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# … | |
from flask_moment import Moment | |
from flask_mail import Mail | |
from flask_login import LoginManager | |
# ... | |
moment = Moment() | |
mail = Mail() | |
login_manager = LoginManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# … | |
from .extensions import bootstrap, db, moment, login_manager, mail | |
from config import config | |
def create_app(config_name): | |
# … | |
login_manager.init_app(app) | |
mail.init_app(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Config: | |
# … | |
MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.googlemail.com') | |
MAIL_PORT = int(os.environ.get('MAIL_PORT', '587')) | |
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'true').lower() in \ | |
['true', 'on', '1'] | |
MAIL_USERNAME = os.environ.get('MAIL_USERNAME') | |
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') | |
SQLALCHEMY_TRACK_MODIFICATIONS = False | |
OFFBRAND_MAIL_SUBJECT_PREFIX = '[Offbrand]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import hashlib | |
from werkzeug.security import generate_password_hash, check_password_hash | |
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer | |
from flask import current_app | |
from flask_login import UserMixin, AnonymousUserMixin | |
from . import db, login_manager | |
class User(db.Model, UserMixin): | |
__tablename__ = 'users' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
from . import db, login_manager | |
class Permission: | |
FOLLOW = 1 | |
COMMENT = 2 | |
WRITE = 4 | |
MODERATE = 8 | |
ADMIN = 16 |