From 00a4c00fcfcc7c142926a54e3e9d9650d482e225 Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Sat, 20 Jul 2024 20:10:18 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AA=8D=E8=A8=BC=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=81=8Cserver.json=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=82=80=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker_auth.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/dislocker_auth.py b/dislocker_auth.py index 2d1453c..71d7b29 100644 --- a/dislocker_auth.py +++ b/dislocker_auth.py @@ -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 = { - "host": "localhost", - "db": "dislocker", - "username": "user", - "password": "example_pass", - "port": "5432" + server_config = { + "db": { + "host": "localhost", + "port": "5432", + "db_name": "dislocker", + "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: - 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():