I'm getting a Invalid Syntax in line 22 @app.route('/start') and really don't know why... I'm developing it under a Cloud9 server https://c9.io , maybe that has something to do with it... I tried it in two virtual enviroments with python versions 2.7.3 and 3.4.3. It's exactly the same syntax of a hello.py that actually does work...
#import random
import string
import hangman
import os
from flask import Flask,
request,
render_template,
url_for,
redirect,
flash
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def initialize():
WORDLIST_FILENAME = "./resources/words.txt"
wordlist = hangman.loadWords(WORDLIST_FILENAME)
return redirect(url_for('start_game', wordlist=wordlist)
@app.route('/start')
def start_game(wordlist):
secretWord = hangman.chooseWord(wordlist).lower()
hangman.hang(secretWord)
return None
if __name__ == '__main__':
#app.debug = True
app.secret_key = 'MySecretKey'
app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT',5000)))
feel free to colaborate branching this project at https://github.com/leomagal/hangman
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…