認証サーバーがserver.jsonの設定ファイルを読み込むように

This commit is contained in:
suti7yk5032 2024-07-20 20:10:18 +09:00
parent 707e2e3ed6
commit 00a4c00fcf

View file

@ -4,23 +4,30 @@ import json
from flask import Flask, request, jsonify, render_template
config_dir_path = "./config/"
db_config_path = config_dir_path + "db.json"
if not os.path.isfile(db_config_path):
server_config_path = config_dir_path + "server.json"
if not os.path.isfile(server_config_path):
if not os.path.isdir(config_dir_path):
os.mkdir(config_dir_path)
db_config = {
server_config = {
"db": {
"host": "localhost",
"db": "dislocker",
"port": "5432",
"db_name": "dislocker",
"username": "user",
"password": "example_pass",
"port": "5432"
"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:
json.dump(db_config, w, indent=4)
elif os.path.isfile(db_config_path):
with open(db_config_path, "r") as r:
db_config = json.load(r)
}
with open(server_config_path, "w") as w:
json.dump(server_config, w, indent=4)
elif os.path.isfile(server_config_path):
with open(server_config_path, "r") as r:
server_config = json.load(r)
class Auth():
def __init__(self, host, db, port, user, password):
@ -42,7 +49,7 @@ class Auth():
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'])
def verify():