gestion des variables d'environement dans le cli
This commit is contained in:
parent
baec9f172f
commit
364c246ef4
|
@ -17,7 +17,11 @@ from .models.api.route import Route
|
||||||
from .models.api.acl_function import AclFunction
|
from .models.api.acl_function import AclFunction
|
||||||
from .models.api.acl import Acl
|
from .models.api.acl import Acl
|
||||||
|
|
||||||
|
# module libraries
|
||||||
|
from halfapi.app import check_conf
|
||||||
|
|
||||||
|
HALFORM_DSN=''
|
||||||
|
HALFORM_SECRET=''
|
||||||
CONTEXT_SETTINGS={
|
CONTEXT_SETTINGS={
|
||||||
'default_map':{'run': {'port': 8000}}
|
'default_map':{'run': {'port': 8000}}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +52,24 @@ def run(host, port, debug, dev):
|
||||||
Port : {port}
|
Port : {port}
|
||||||
Debug : {debug}
|
Debug : {debug}
|
||||||
Dev : {dev}''')
|
Dev : {dev}''')
|
||||||
|
|
||||||
|
HALFORM_DSN=os.environ.get('HALFORM_DSN', '')
|
||||||
|
db_params = dsntodict(HALFORM_DSN)
|
||||||
|
if not hasattr(db_params, 'dbname'):
|
||||||
|
db_params['dbname'] = dbname
|
||||||
|
if not hasattr(db_params, 'host'):
|
||||||
|
db_params['host'] = dbhost
|
||||||
|
if not hasattr(db_params, 'port'):
|
||||||
|
db_params['port'] = dbport
|
||||||
|
if not hasattr(db_params, 'user'):
|
||||||
|
db_params['user'] = dbuser
|
||||||
|
if not hasattr(db_params, 'password'):
|
||||||
|
db_params['password'] = dbpassword
|
||||||
|
|
||||||
|
os.environ['HALFORM_DSN'] = dicttodsn(db_params)
|
||||||
|
|
||||||
|
check_conf()
|
||||||
|
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
click.echo(sys.path)
|
click.echo(sys.path)
|
||||||
uvicorn.run('halfapi.app:app',
|
uvicorn.run('halfapi.app:app',
|
||||||
|
|
|
@ -56,7 +56,7 @@ def parse_query(q: str = ""):
|
||||||
>>> parse_query('limit=10')
|
>>> parse_query('limit=10')
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
fastapi.exceptions.HTTPException: 400
|
starlette.exceptions.HTTPException: 400
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue