-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfiguration.py
42 lines (32 loc) · 955 Bytes
/
Configuration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
global g_blockedMethods,Redirects
g_blockedMethods = []
Redirects = {}
global HOST,PORT,VERSION
HOST = "localhost"
PORT = 1300
VERSION = "0.1.2"
def read_AllConfig():
for x in registeredConfigFiles.keys():
registeredConfigFiles[x](read_ConfigFile(x))
def read_ConfigFile(filename : str):
'''
filename <- str
return -> Dict
'''
try:
with open(f"config/{filename}") as f:
return json.loads(f.read())
except:
print("Failed to read Configuration File")
return json.loads("{}")
def load_GlobalConfig(config : dict):
global g_blockedMethods,Redirects
g_blockedMethods = config["BlockedMethods"]
Redirects = config["Redirects"]
global HOST,PORT
HOST = config["SocketSettings"]["HOST"]
PORT = config["SocketSettings"]["PORT"]
registeredConfigFiles = {
"globalConfiguration.json" : load_GlobalConfig
}