mirror of
https://github.com/IgorL123/mafia_api.git
synced 2026-09-24 07:30:15 +00:00
upd 0.3
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
venv
|
||||
setiings.json
|
||||
.vscode
|
||||
@@ -8,21 +8,22 @@ app = Flask(__name__)
|
||||
def hello_world(): # put application's code here
|
||||
return 'Hello World!'
|
||||
|
||||
|
||||
@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,10 +11,12 @@ db_params = {
|
||||
connection = psycopg2.connect(**db_params)
|
||||
cursor = connection.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)
|
||||
@@ -22,13 +24,13 @@ def query_ins_user(x, curs = cursor):
|
||||
|
||||
def query_ins_chat(x, curs=cursor):
|
||||
try: # Запрос добавления чата
|
||||
curs.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
|
||||
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):
|
||||
try:
|
||||
# Запрос вывода из БД
|
||||
@@ -41,6 +43,7 @@ def query_sel(x, curs = cursor):
|
||||
except Exception as e:
|
||||
print("Ошибка:", e)
|
||||
|
||||
|
||||
def query_change(x):
|
||||
# Написать выдачу резов по ролям
|
||||
pass
|
||||
@@ -49,4 +52,3 @@ def query_change(x):
|
||||
def close(cur=cursor, conn=connection):
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user