2024-02-18 16:44:57 +00:00
|
|
|
import os
|
|
|
|
import json
|
|
|
|
|
|
|
|
if not os.path.exists('config.json'):
|
2024-08-19 11:17:58 +00:00
|
|
|
db = {'os': None,'our_port': 0000, 'ports': [], 'base_url': 'http://0.0.0.0:8000'}
|
2024-02-18 16:44:57 +00:00
|
|
|
js = json.dumps(db, indent=2)
|
2024-08-19 11:17:58 +00:00
|
|
|
with open('config.json', 'w') as outfile:
|
2024-02-18 16:44:57 +00:00
|
|
|
outfile.write(js)
|
|
|
|
print('Created new config.json')
|
|
|
|
|
|
|
|
|
|
|
|
def read(file = 'config.json'):
|
2024-08-19 11:17:58 +00:00
|
|
|
with open(file, 'r', encoding='utf-8') as openfile:
|
2024-02-18 16:44:57 +00:00
|
|
|
db = json.load(openfile)
|
|
|
|
return db
|
|
|
|
|
|
|
|
def write(db, file = 'config.json'):
|
|
|
|
js = json.dumps(db, indent=2, ensure_ascii=False)
|
2024-08-19 11:17:58 +00:00
|
|
|
with open(file, 'w', encoding='utf-8') as outfile:
|
2024-02-18 16:44:57 +00:00
|
|
|
outfile.write(js)
|