-1

I encountered some problems when trying to open the link provided by the flask. I have updated my code and when I run and open the link only hello world is displayed and not the current code. Can someone explain why pls?

Also the review page asks for the user to input their name and I tried this as code in the python flask although I can't check if this will get the user input due to the problem mentioned above. Does this code make sense?

from flask import Flask,request,render_template  

app = Flask(__name__)

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/")
def name():
    name = request("name")

Austin M
  • 1
  • 1

1 Answers1

1

The problem is that you have the same route twice.

You have to use different routes for different endpoints.

Example:

from flask import Flask, render_template, request

app = Flask(__name__)

@app.route("/")
def index():

    return render_template("index.html")

@app.route("/name")
def name():

    return "This is the name endpoint."

When you go to /name, you should see 'This is the name endpoint.'.