Add external configuration

This commit is contained in:
Sébastien Copin 2023-07-08 20:50:49 +02:00
parent 5b5ecace85
commit b138364323
4 changed files with 20 additions and 6 deletions

View file

@ -1,2 +1,3 @@
redis
falcon
dynaconf

View file

@ -10,14 +10,15 @@ import shutil
import xml.sax
import redis
import time
from dynaconf import Dynaconf
# Configuration
cpe_path = '../data/official-cpe-dictionary_v2.3.xml'
cpe_source = (
'https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz'
settings = Dynaconf(
settings_files=['../config/settings.yaml']
)
rdb = redis.Redis(host='127.0.0.1', port=6379, db=8)
cpe_path = settings.cpe.path
cpe_source = (settings.cpe.source)
rdb = redis.Redis(host=settings.redis.host, port=settings.redis.port, db=8)
class CPEHandler(xml.sax.ContentHandler):
def __init__(self):

View file

@ -6,9 +6,13 @@ import sys
import falcon
from wsgiref.simple_server import make_server
import json
from dynaconf import Dynaconf
# Configuration
port = 8000
settings = Dynaconf(
settings_files=['../config/settings.yaml']
)
port = settings.server.port
runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))

8
config/settings.yaml Normal file
View file

@ -0,0 +1,8 @@
server:
port: 8000
redis:
host: 127.0.0.1
port: 6379
cpe:
path: '../data/official-cpe-dictionary_v2.3.xml'
source: 'https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz'