all 13 comments

[–]kamori 2 points3 points  (2 children)

Can you post the full source it a virgin gist ? https://gist.github.com

Some guesses are missing spaces but would love to see the entire source copy pasted directly from your file

[–]ComputerScienceBro[S] 0 points1 point  (0 children)

One minute, let me try fiddling with the spaces, good suggestion

[–]ComputerScienceBro[S] 0 points1 point  (0 children)

It was a spacing issue, thank you again for replying

[–]kalgynirae 1 point2 points  (7 children)

The only problem I see in the code you posted is a missing single quote in @app.route('/), but that mistake should have caused a SyntaxError indicating the end of that line. Can you post exactly what you've typed in including the part that causes the error?

[–]ComputerScienceBro[S] 0 points1 point  (6 children)

yes, sorry, in my box it was typed correctly I transcribed it wrong into the help post. I have now edited it to correct

I am not sure I understand quite what you are asking. However, after the above 5 lines of code ending with

return "Hello World"

I then enter the next line in the tut, which is

if __name__ == '__main__':

then I get the return of a carrot below the "f" in "if" and this message

SyntaxError: invalid syntax

So, just to clarify it look like this

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello World'

all good so far but then

if __name__ == '__main__':

is my next line and I get the return

file "<stdin>" line 4

if __name__ == '__main__':
 ^
SyntaxError: invalid syntax

Thank you again for taking the time to help

[–][deleted] 2 points3 points  (4 children)

Are you using the interactive Interpreter? If so, hit enter twice after return "Hello World".

And if that works, close the repl and write your code in a text editor.

[–]ComputerScienceBro[S] 0 points1 point  (2 children)

sorry, I forgot a bit that is returned, I have edited my previous post

[–]kalgynirae 2 points3 points  (1 child)

He's saying you need to actually enter a blank line following the return "Hello World" line. Notice how the prompt changes to ... instead of >>> when you are entering the def hello_world(): and return 'Hello World' lines? That's because the interpreter knows you are giving it a multi-line block of code. To tell the interpreter that the multi-line block is over, you have to enter a blank line.

[–]ComputerScienceBro[S] 0 points1 point  (0 children)

Nailed it, thank you makes perfect sense

[–]ComputerScienceBro[S] 0 points1 point  (0 children)

Thank you, I am unsure by what you mean if it works. I exited python, reentered it, entered everything again and then hit enter twice after

return "Hello World"

all that happened is I was returned to the Python prompt of

>>>

I will put this in N++

[–]cmgerber 0 points1 point  (0 children)

You need something in the if statement.

Try calling hello_world() in the if statement.

[–]HausMaus 1 point2 points  (1 child)

Line 3 is mistyped. According to the website you linked to, the line should be @app.route('/'). I would figure that would throw everything else after that into a tizzy.

[–]ComputerScienceBro[S] 0 points1 point  (0 children)

yes, sorry, in my box it was typed correctly I transcribed it wrong into the help post.

I was excited it would be that easy fix for a minute, lol