remove session cookie when server restarts
This commit is contained in:
parent
e8bf27d2ef
commit
6acc73abd2
23
app.py
23
app.py
|
@ -1,5 +1,6 @@
|
|||
from flask import Flask, render_template, request, session
|
||||
from flask import Flask, render_template, request, session, make_response
|
||||
import random
|
||||
import socket
|
||||
import time
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -12,7 +13,10 @@ moves = ['forward', 'forward x2', 'forward x3', 'backward', 'turn left', 'turn r
|
|||
class Game:
|
||||
def __init__(self):
|
||||
self.action_stack = {}
|
||||
self.processing_done = False
|
||||
self.processing_done = False # indicates whether all commands in the current round have been processed
|
||||
|
||||
self.comm_socket = socket.socket() # socket for communicating with the program controlling the robots
|
||||
|
||||
|
||||
def ready(self):
|
||||
# have all players chosen an action?
|
||||
|
@ -35,6 +39,9 @@ class Game:
|
|||
current_actions += [(p, self.action_stack[p][i])]
|
||||
print("actions in step {}: {}".format(i, ["robot {} action {}".format(c[0], c[1]) for c in current_actions]))
|
||||
|
||||
#self.comm_socket.send()
|
||||
|
||||
|
||||
# clear the action stack for the next round
|
||||
self.action_stack = {}
|
||||
|
||||
|
@ -116,11 +123,19 @@ def hello_world():
|
|||
p = Player()
|
||||
session['player_id'] = p.id
|
||||
players[p.id] = p
|
||||
player_id = session['player_id']
|
||||
else:
|
||||
return "Sorry, maximum number of players reached!"
|
||||
|
||||
player_id = session['player_id']
|
||||
else:
|
||||
player_id = session['player_id']
|
||||
if Player.player_counter < player_id + 1:
|
||||
session.clear()
|
||||
response = make_response('Please reload the page!')
|
||||
#response.set_cookie('player_id', '', expires=0)
|
||||
return response
|
||||
player_hand = players[player_id].player_hand
|
||||
|
||||
|
||||
if request.method == 'GET':
|
||||
return render_template('drag_example.html', cmds=player_hand, player_id=player_id)
|
||||
elif request.method == 'POST':
|
||||
|
|
Loading…
Reference in New Issue
Block a user