DEV Community

Discussion on: Learn Flask by coding

Collapse
 
pwarde profile image
Erik • Edited

Thanks for this introduction to flask!
Very helpful!

I found that returning 'Hello Coder, you are up!' outside of a function does not work (as in example 1). Putting it in 'def hello():' (as in example 2) does work.

Collapse
 
sm0ke profile image
Sm0ke

Hello Eric,
Thanks :)

The print should be inside the hello() method.
Did you clone the app from Github?

Collapse
 
pwarde profile image
Erik

Hi,

No, I just read your article and typed the few lines of code myself.
So only the first example:

from flask import Flask
app = Flask(__name__)

@app.route('/')
    return 'Hello Coder, you are up!'

Gives a syntax error and should be:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello Coder, you are up!'

That is all. But might be important for a #beginners post.

Thread Thread
 
sm0ke profile image
Sm0ke

Done. Thank you!