認証サーバーがserver.jsonの設定ファイルを読み込むように
This commit is contained in:
parent
707e2e3ed6
commit
00a4c00fcf
1 changed files with 21 additions and 14 deletions
|
@ -4,23 +4,30 @@ import json
|
||||||
from flask import Flask, request, jsonify, render_template
|
from flask import Flask, request, jsonify, render_template
|
||||||
|
|
||||||
config_dir_path = "./config/"
|
config_dir_path = "./config/"
|
||||||
db_config_path = config_dir_path + "db.json"
|
server_config_path = config_dir_path + "server.json"
|
||||||
if not os.path.isfile(db_config_path):
|
if not os.path.isfile(server_config_path):
|
||||||
if not os.path.isdir(config_dir_path):
|
if not os.path.isdir(config_dir_path):
|
||||||
os.mkdir(config_dir_path)
|
os.mkdir(config_dir_path)
|
||||||
|
|
||||||
db_config = {
|
server_config = {
|
||||||
"host": "localhost",
|
"db": {
|
||||||
"db": "dislocker",
|
"host": "localhost",
|
||||||
"username": "user",
|
"port": "5432",
|
||||||
"password": "example_pass",
|
"db_name": "dislocker",
|
||||||
"port": "5432"
|
"username": "user",
|
||||||
|
"password": "password"
|
||||||
|
},
|
||||||
|
"bot": {
|
||||||
|
"token": "TYPE HERE BOTS TOKEN KEY",
|
||||||
|
"log_channel_id" : "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)",
|
||||||
|
"config_channel_id": "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
with open(db_config_path, "w") as w:
|
with open(server_config_path, "w") as w:
|
||||||
json.dump(db_config, w, indent=4)
|
json.dump(server_config, w, indent=4)
|
||||||
elif os.path.isfile(db_config_path):
|
elif os.path.isfile(server_config_path):
|
||||||
with open(db_config_path, "r") as r:
|
with open(server_config_path, "r") as r:
|
||||||
db_config = json.load(r)
|
server_config = json.load(r)
|
||||||
|
|
||||||
class Auth():
|
class Auth():
|
||||||
def __init__(self, host, db, port, user, password):
|
def __init__(self, host, db, port, user, password):
|
||||||
|
@ -42,7 +49,7 @@ class Auth():
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__, static_folder="./resource/")
|
app = Flask(__name__, static_folder="./resource/")
|
||||||
auth = Auth(db_config["host"], db_config["db"], db_config["port"], db_config["username"], db_config["password"])
|
auth = Auth(server_config["db"]["host"], server_config["db"]["db_name"], server_config["db"]["port"], server_config["db"]["username"], server_config["db"]["password"])
|
||||||
|
|
||||||
@app.route('/verify', methods=['POST'])
|
@app.route('/verify', methods=['POST'])
|
||||||
def verify():
|
def verify():
|
||||||
|
|
Loading…
Reference in a new issue