This commit is contained in:
ada-dmitry
2023-08-22 15:47:26 +03:00
parent 8e05627782
commit c1ebc405d4
3 changed files with 20 additions and 16 deletions
+1
View File
@@ -1,2 +1,3 @@
venv
setiings.json
.vscode
+4 -3
View File
@@ -8,21 +8,22 @@ app = Flask(__name__)
def hello_world(): # put application's code here
return 'Hello World!'
@app.route('/create_game', methods = ["POST"])
@app.route('/create_game', methods=["POST"])
def create():
TCI = request.json
db.query_ins_chat(TCI)
@app.route('/start_game')
def start(): # Команда принимает на вход
pass
@app.route('/action')
def action():
pass
if __name__ == '__main__':
app.run()
+11 -9
View File
@@ -11,25 +11,27 @@ db_params = {
connection = psycopg2.connect(**db_params)
cursor = connection.cursor()
def query_ins_user(x, curs = cursor):
def query_ins_user(x, curs=cursor):
try:
# Запрос добавления пользователя
curs.execute(f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""")
curs.execute(
f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""")
curs.commit()
except Exception as e:
print("Ошибка:", e)
def query_ins_chat(x, curs = cursor):
try: # Запрос добавления чата
curs.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
def query_ins_chat(x, curs=cursor):
try: # Запрос добавления чата
curs.execute(
f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
curs.commit()
except Exception as e:
print("Ошибка:", e)
def query_sel(x, curs = cursor):
def query_sel(x, curs=cursor):
try:
# Запрос вывода из БД
curs.execute("SELECT * FROM chats")
@@ -41,12 +43,12 @@ def query_sel(x, curs = cursor):
except Exception as e:
print("Ошибка:", e)
def query_change(x):
# Написать выдачу резов по ролям
pass
def close(cur = cursor, conn = connection):
def close(cur=cursor, conn=connection):
cursor.close()
connection.close()