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