Compare commits

..

2 commits

Author SHA1 Message Date
ab92ecfb4a sqlite用にちょっと変更 2024-06-04 14:17:35 +09:00
83e44da330 フォルダだけ同期するように 2024-06-04 14:17:11 +09:00
3 changed files with 8 additions and 14 deletions

4
.gitignore vendored
View file

@ -160,5 +160,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
config config/*
db db/*

View file

@ -40,13 +40,13 @@ class Cert():
def register(self, username, userid): def register(self, username, userid):
cursor = self.db.cursor() cursor = self.db.cursor()
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (%s, %s);" insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (?, ?);"
cursor.execute(insert_sql, (username, userid)) cursor.execute(insert_sql, (username, userid))
self.db.commit() self.db.commit()
def get_username(self, username, password): def get_username(self, username, password):
cursor = self.db.cursor() cursor = self.db.cursor()
get_sql = "SELECT * FROM web_auth WHERE username = %s AND password = %s " get_sql = "SELECT * FROM web_auth WHERE username = ? AND password = ? "
cursor.execute(get_sql, (username, password)) cursor.execute(get_sql, (username, password))
result = cursor.fetchall() result = cursor.fetchall()
print(result) print(result)
@ -55,14 +55,8 @@ class Cert():
elif result[0][1] == username and result[0][2] == password: elif result[0][1] == username and result[0][2] == password:
return 0 return 0
class Web(flask.Flask):
async def temp(self):
print("")
cert = Cert() cert = Cert()
print(cert.get_username("suti7", "0126"))
bot_config_path = "./config/bot.json" bot_config_path = "./config/bot.json"
if not os.path.isfile(bot_config_path): if not os.path.isfile(bot_config_path):

View file

@ -1,6 +1,6 @@
from flask import Flask, request, render_template, redirect, url_for from flask import Flask, request, render_template, redirect, url_for
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user
import psycopg2 import sqlite3
app = Flask(__name__, static_folder="./resource/") app = Flask(__name__, static_folder="./resource/")
app.secret_key = 'your_secret_key' app.secret_key = 'your_secret_key'
@ -9,17 +9,17 @@ login_manager.init_app(app)
class Cert(): class Cert():
def __init__(self): def __init__(self):
self.db = psycopg2.connect("host=localhost dbname=dislocker user=suti7 password=testing") self.db = sqlite3.connect("host=localhost dbname=dislocker user=suti7 password=testing")
def register(self, username, userid): def register(self, username, userid):
cursor = self.db.cursor() cursor = self.db.cursor()
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (%s, %s);" insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (?, ?)"
cursor.execute(insert_sql, (username, userid)) cursor.execute(insert_sql, (username, userid))
self.db.commit() self.db.commit()
def login(self, username, password): def login(self, username, password):
cursor = self.db.cursor() cursor = self.db.cursor()
get_sql = "SELECT * FROM web_auth WHERE username = %s AND password = %s " get_sql = "SELECT * FROM web_auth WHERE username = ? AND password = ? "
cursor.execute(get_sql, (username, password)) cursor.execute(get_sql, (username, password))
result = cursor.fetchall() result = cursor.fetchall()
print(result) print(result)