Remove const module.
This commit is contained in:
4
app.py
4
app.py
@@ -8,14 +8,12 @@ from flask_bootstrap import Bootstrap
|
|||||||
import db
|
import db
|
||||||
import forms
|
import forms
|
||||||
import models
|
import models
|
||||||
import const
|
|
||||||
from config import Config
|
from config import Config
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(filename=const.LOG_PATH, level=logging.DEBUG)
|
logging.basicConfig(filename=Config.LOG_PATH, level=logging.DEBUG)
|
||||||
|
|
||||||
logging.info(f"Starting in working dir: {os.getcwd()}")
|
logging.info(f"Starting in working dir: {os.getcwd()}")
|
||||||
logging.info(f"App base path: {const.BASE_PATH}")
|
|
||||||
|
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
|
|||||||
8
conf.sh
8
conf.sh
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
export READ_PW=""
|
export ES_READ_PW=""
|
||||||
export WRITE_PW=""
|
export ES_WRITE_PW=""
|
||||||
export SECRET_KEY=""
|
export ES_SECRET_KEY=""
|
||||||
|
export ES_DATABASE_PATH=""
|
||||||
|
export ES_LOG_PATH=""
|
||||||
@@ -5,3 +5,5 @@ class Config:
|
|||||||
SECRET_KEY = os.environ.get("ES_SECRET_KEY")
|
SECRET_KEY = os.environ.get("ES_SECRET_KEY")
|
||||||
WRITE_PW = os.environ.get("ES_WRITE_PW")
|
WRITE_PW = os.environ.get("ES_WRITE_PW")
|
||||||
READ_PW = os.environ.get("ES_READ_PW")
|
READ_PW = os.environ.get("ES_READ_PW")
|
||||||
|
DATABASE_PATH = os.environ.get("ES_DATABASE_PATH")
|
||||||
|
LOG_PATH = os.environ.get("ES_LOG_PATH")
|
||||||
|
|||||||
9
const.py
9
const.py
@@ -1,9 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
BASE_PATH = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
|
||||||
DATABASE_NAME = "es_debug.db"
|
|
||||||
DATABASE_PATH = os.path.join(BASE_PATH, DATABASE_NAME)
|
|
||||||
|
|
||||||
LOG_NAME = "estus-shots.log"
|
|
||||||
LOG_PATH = os.path.join(BASE_PATH, LOG_NAME)
|
|
||||||
6
db.py
6
db.py
@@ -3,15 +3,15 @@ import logging as log
|
|||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
import models
|
import models
|
||||||
import const
|
from config import Config
|
||||||
|
|
||||||
|
|
||||||
def connect_db():
|
def connect_db():
|
||||||
"""Create a new sqlite3 connection and register it in 'g._database'"""
|
"""Create a new sqlite3 connection and register it in 'g._database'"""
|
||||||
db = getattr(g, "_database", None)
|
db = getattr(g, "_database", None)
|
||||||
if db is None:
|
if db is None:
|
||||||
log.info(f"Connecting {const.DATABASE_NAME}")
|
log.info(f"Connecting {Config.DATABASE_PATH}")
|
||||||
db = g._database = sqlite3.connect(const.DATABASE_PATH)
|
db = g._database = sqlite3.connect(Config.DATABASE_PATH)
|
||||||
|
|
||||||
db.row_factory = sqlite3.Row
|
db.row_factory = sqlite3.Row
|
||||||
return db
|
return db
|
||||||
|
|||||||
Reference in New Issue
Block a user