fix: create config file if doesn't exist
This commit is contained in:
parent
557d592201
commit
c72351a221
23
config.py
23
config.py
@ -1,7 +1,22 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
f = open('./config/config.json')
|
try:
|
||||||
|
f = open('./config/config.json')
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
except:
|
||||||
|
data = {
|
||||||
|
"database": {
|
||||||
|
"ip": "localhost",
|
||||||
|
"port": 3306,
|
||||||
|
"user": "user",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object = json.dumps(dictionary, indent=4)
|
||||||
|
|
||||||
|
with open("config/config.json", "w") as outfile:
|
||||||
|
outfile.write(json_object)
|
||||||
|
|
||||||
|
|
||||||
database = data.get("database");
|
database = data.get("database");
|
||||||
|
Loading…
Reference in New Issue
Block a user