add config.py

develop
gwen 2 years ago
parent f40127b264
commit 1f577c04bd

2
.gitignore vendored

@ -1,2 +1,2 @@
.venv/* .venv/*
params.yaml

@ -0,0 +1,19 @@
"""Application's configuration file"""
from pathlib import Path
# path configuration
# let's guess that :file:`config.py` is located here : :file:`{rootpath}/webapp/`
_here = Path(__file__).resolve().parent
rootpath = _here.parent
"root project directory"
from yaml import safe_load
# loads database credentials
local_params_file = rootpath / "params.yaml"
with open(local_params_file, 'r') as file_handle:
params_content = safe_load(file_handle)
dbadmin = params_content['dbadmin']
dbpassword = params_content['dbpassword']

@ -1,15 +1,15 @@
import typing as t import typing as t
import urllib.parse
from flask import Blueprint, abort, render_template, request, send_from_directory from flask import Blueprint, abort, render_template, request, send_from_directory
main = Blueprint("main", __name__, url_prefix="/")
from pymongo import MongoClient from pymongo import MongoClient
import urllib.parse from .config import dbadmin, dbpassword
main = Blueprint("main", __name__, url_prefix="/")
username = urllib.parse.quote_plus('dbadmin') username = urllib.parse.quote_plus(dbadmin)
password = urllib.parse.quote_plus('BrOp48la%Mrops') password = urllib.parse.quote_plus(dbpassword)
myclient = MongoClient('mongodb://%s:%s@149.202.41.75:27017' % (username, password)) myclient = MongoClient('mongodb://%s:%s@149.202.41.75:27017' % (username, password))
mydb = myclient["actesdb"] mydb = myclient["actesdb"]
dbhouse = mydb["house"] dbhouse = mydb["house"]

@ -21,3 +21,5 @@ Werkzeug==2.3.7
Flask-WTF==1.1.1 Flask-WTF==1.1.1
WTForms==3.0.1 WTForms==3.0.1
zipp==3.9.0 zipp==3.9.0
pyyaml-6.0.1

Loading…
Cancel
Save