import passwords import funcs from os import environ from http.cookies import SimpleCookie import pymysql as db cookie = SimpleCookie() http_cookie_header = environ.get("HTTP_COOKIE") if http_cookie_header: cookie.load(http_cookie_header) try: if funcs.check_if_exists(cookie["sessionId"].value): connection = db.connect(passwords.serverip, passwords.servername, passwords.serverpass, passwords.db_name) cursor = connection.cursor(db.cursors.DictCursor) cursor.execute("""UPDATE users SET sessionId=NULL WHERE sessionId= %s""", (cookie["sessionId"].value)) connection.commit() cursor.close() connection.close() funcs.redirect("index.py") else: funcs.redirect("index.py") except: funcs.redirect("index.py")
FROM chess_games WHERE game_id = %s""", (gid)) for row in cursor.fetchall(): connection.commit() cursor.close() connection.close() return row["player_1"], row["player_2"] ###### print("Content-Type: text/plain") print() try: if funcs.check_if_exists(cookie): uname = funcs.return_uname(cookie) m = funcs.is_ongoing_game(uname) if m: session_store = open("session_" + str(m[1]), writeback=True) board = session_store["board"] turn = session_store["turn"] move = convert_verify(move) if move[0]: move = move[1] colour = player_colour(uname, session_store) possible_valid_move = possible_valid_move( colour, move, board, turn) if possible_valid_move[0]: piece = board[move[0][0]][move[0][1]][1] if piece == "p":