mirror of
https://github.com/IgorL123/mafia_api.git
synced 2026-09-23 23:20:19 +00:00
upd 0.3
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
venv
|
venv
|
||||||
setiings.json
|
setiings.json
|
||||||
|
.vscode
|
||||||
@@ -8,21 +8,22 @@ app = Flask(__name__)
|
|||||||
def hello_world(): # put application's code here
|
def hello_world(): # put application's code here
|
||||||
return 'Hello World!'
|
return 'Hello World!'
|
||||||
|
|
||||||
@app.route('/create_game', methods = ["POST"])
|
|
||||||
|
@app.route('/create_game', methods=["POST"])
|
||||||
def create():
|
def create():
|
||||||
TCI = request.json
|
TCI = request.json
|
||||||
db.query_ins_chat(TCI)
|
db.query_ins_chat(TCI)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/start_game')
|
@app.route('/start_game')
|
||||||
def start(): # Команда принимает на вход
|
def start(): # Команда принимает на вход
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@app.route('/action')
|
@app.route('/action')
|
||||||
def action():
|
def action():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
||||||
@@ -11,25 +11,27 @@ db_params = {
|
|||||||
connection = psycopg2.connect(**db_params)
|
connection = psycopg2.connect(**db_params)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
def query_ins_user(x, curs = cursor):
|
|
||||||
|
def query_ins_user(x, curs=cursor):
|
||||||
try:
|
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()
|
curs.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
|
||||||
def query_ins_chat(x, curs = cursor):
|
def query_ins_chat(x, curs=cursor):
|
||||||
try: # Запрос добавления чата
|
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()
|
curs.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
|
||||||
|
def query_sel(x, curs=cursor):
|
||||||
def query_sel(x, curs = cursor):
|
|
||||||
try:
|
try:
|
||||||
# Запрос вывода из БД
|
# Запрос вывода из БД
|
||||||
curs.execute("SELECT * FROM chats")
|
curs.execute("SELECT * FROM chats")
|
||||||
@@ -41,12 +43,12 @@ def query_sel(x, curs = cursor):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
|
||||||
def query_change(x):
|
def query_change(x):
|
||||||
# Написать выдачу резов по ролям
|
# Написать выдачу резов по ролям
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def close(cur = cursor, conn = connection):
|
def close(cur=cursor, conn=connection):
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user