def restart(): # TODO make restart functionality global WORD,gametries,Guess Word = db_instance.models['word'] WORD = WordApi.get_word() print(WORD) GAME_DATA = init_game_data(WORD) Guess = GAME_DATA['GuessLetters'] print(Guess) gametries=GAME_DATA['tries'] print(gametries) print('estoy en restart') return redirect('/') return render_template( 'index.html', instruction1=constants.INSTRUCTION1, instruction2=constants.INSTRUCTION2, instruction3=constants.INSTRUCTION3, game=GAME_DATA,gametries=gametries,letters=letters,final=final)
from config.api import WordApi app = Flask(__name__) # referencing current file CORS(app) db_instance = DB(app) crud_methods = ['GET', 'POST'] Word = db_instance.models['word'] WORD = WordApi.get_word() print(WORD) GAME_DATA = init_game_data(WORD) #url sin ningún parámetro @app.route('/', methods=crud_methods) def index(): print('estoy en home') global WORD if request.method == 'POST': req = request.form input= utils.word_to_uppercase (req['letter']) game_finished= utils.game_over( GAME_DATA ['letters'], GAME_DATA ['tries']) if(not game_finished and validations.valid_letter(input) find_indexes= utils.find_indexes_in_string (input, GAME_DATA ['word']) if (find_indexes):