Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
313 views
Welcome To Ask or Share your Answers For Others

1 Answer

Missing a closing parenthesis on:

return redirect(url_for('start_game', wordlist=wordlist)

If you get a syntax error, if the problem isn't obvious in the line the error reports, look at previous lines for issues like missing parenthesis.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...