Python Flask Basics Welcome to Flask Request args

Vanessza Koos
Vanessza Koos
555 Points

Hi, I got this error message: Bummer: '/' gave a non-200 response. Did you change the route? Anybody any idea?

Hi, I got this error message: Bummer: '/' gave a non-200 response. Did you change the route? Anybody any idea what is the problem?

flask_app.py
from flask import Flask
from flask import request

app = Flask(__name__)

@app.route('/')
def index(name):
     return "Hello {}".format(name)
Christian Beckett
Christian Beckett
10,559 Points

Hi Vanessza. It looks to me like you just looked over something wrong. look at it again Vanessza Koos :P

1 Answer

Christian Beckett
Christian Beckett
10,559 Points

Or in my opinion it should look something like this

from flask import Flask
from flask import request

app = Flask(__name__)


app.route('/')
def index(name='Christian'):
    name = request.args.get('name', name)
    return 'Hello {}!'.format(name)

Good luck on your python adventure. Hope this helps some :3 Vanessza Koos

Christian Beckett
Christian Beckett
10,559 Points

Your welcome sorry it took me a while to answer. I'm learning python frameworks myself so if you need help please just ping me i will help Vanessza Koos

Vanessza Koos
Vanessza Koos
555 Points

All right I'll thank you!