Add environment variables
This commit is contained in:
parent
606c343f53
commit
d04d93eb7a
17
app.py
17
app.py
|
@ -1,20 +1,21 @@
|
|||
from flask import Flask
|
||||
from os import urandom
|
||||
|
||||
from apps.admin import admin as blueprint_admin
|
||||
from apps.auth import auth as blueprint_auth
|
||||
|
||||
from database.models import build_models
|
||||
|
||||
import logging
|
||||
|
||||
from apps.admin import admin as blueprint_admin
|
||||
from apps.auth import auth as blueprint_auth
|
||||
|
||||
from config import secret_key
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = urandom(24)
|
||||
app.secret_key = secret_key
|
||||
|
||||
app.register_blueprint(blueprint_auth)
|
||||
app.register_blueprint(blueprint_admin)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from database import build_database
|
||||
build_database()
|
||||
logging.info("Build database models")
|
||||
build_models()
|
||||
|
||||
app.run(host="0.0.0.0")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from flask import Blueprint,render_template,request,redirect,url_for,session
|
||||
from werkzeug.security import check_password_hash
|
||||
|
||||
from database.models import WebUser
|
||||
from database import WebUser
|
||||
|
||||
auth = Blueprint('auth',__name__)
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
from environs import Env
|
||||
from os import urandom
|
||||
|
||||
env = Env()
|
||||
env.read_env()
|
||||
|
||||
db_url = env.str("db_url")
|
||||
secret_key = urandom(48)
|
|
@ -1,10 +1,9 @@
|
|||
from peewee import Model,CharField
|
||||
|
||||
from playhouse.db_url import connect
|
||||
|
||||
|
||||
# TODO: create connection to bot database
|
||||
db = connect("sqlite:///db.db")
|
||||
|
||||
from config import db_url
|
||||
db = connect(db_url)
|
||||
|
||||
class WebUser(Model):
|
||||
username = CharField()
|
||||
|
@ -25,5 +24,5 @@ class WebUser(Model):
|
|||
|
||||
return False
|
||||
|
||||
def build_models():
|
||||
def build_database():
|
||||
db.create_tables([WebUser])
|
|
@ -1 +0,0 @@
|
|||
from models import WebUser
|
Loading…
Reference in New Issue