I am designing this simple website using Flask. But I am getting a 404 error for my hello method. Whenever I click on the button "rate artists," it's giving me the error, but templates for home.html, hello.html, and artist.html are all correct. I do not know what part of my code is wrong. Any help?
@app.route("/",methods=['GET','POST'])
def login():
if request.method=="GET":
return render_template("home.html")
if request.method=="POST":
if (request.form["button"]=="login"):
return render_template("hello.html",name=request.form["name"])
@app.route("/hello",methods=['GET','POST'])
def hello():
if request.method=="GET":
if(request.form["button"]=="rate artists"):
return render_template("artist.html")
For whatever reason I encountered this when I set the SERVER_NAME to
127.0.0.1
instead oflocalhost
. I don't know why that was important with my setup, but after changing it tolocalhost
everything started working again.I'm having the same problem.
I'm doing some experimental CORS tests between backbone and Flask as an endpoint in a different url
Are you using SERVER_NAME in your Config object or when you use the app.run ?
I put the SERVER_NAME but did not specify the port,
Server name doesn't has the port
I also was getting 404 for any of the routes I had defined (if you are interested, I'm using blueprints)
When I send a request to my flask app using curl, I was getting 404, here is the output I was getting 404 for all of the blueprints that I had defined
So, check if you have defined the config variable SERVER_NAME and it has the port