added new folder and ran tests
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from app import app
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# prepare optional local setup
|
||||
env_path = Path(__file__).parent.parent.parent / 'local.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
|
||||
# ensure env vars set
|
||||
necesasary_var_list = {
|
||||
'MONGO_HOST',
|
||||
'MONGO_DB',
|
||||
'MONGO_COLLECTION',
|
||||
'MONGO_USER',
|
||||
'MONGO_PASSWORD',
|
||||
'DASH_AUTH_USERNAME',
|
||||
'DASH_AUTH_PASSWORD',
|
||||
}
|
||||
for env_var in necesasary_var_list:
|
||||
# ensure env var set
|
||||
assert (
|
||||
env_var in os.environ
|
||||
), (
|
||||
f"environment variable not set: {env_var}"
|
||||
)
|
||||
|
||||
# setup logging stream handler
|
||||
FMT = (
|
||||
'%(asctime)s | '
|
||||
'%(levelname)s | '
|
||||
'%(filename)s | '
|
||||
'%(funcName)s | '
|
||||
'%(message)s'
|
||||
)
|
||||
DATEFMT = '%Y-%m-%d %H:%M:%S'
|
||||
logging.basicConfig(format=FMT, datefmt=DATEFMT, level=logging.INFO)
|
||||
|
||||
logging.info('initialized app')
|
||||
server = app.server
|
||||
server.config.update(SECRET_KEY=os.urandom(24))
|
||||
|
||||
if __name__ == '__main__':
|
||||
# prepare local env vars
|
||||
os.environ['MONGO_HOST'] = 'localhost'
|
||||
# run app
|
||||
app.run(debug=True)
|
||||
logging.info('started app')
|
||||
Reference in New Issue
Block a user