it shows the function related to root url i.e. ('/') but if i write @app.route('/home') it gives me that error
it shows the function related to root url i.e. ('/') but if i write @app.route('/home') it gives me that error
I don't know if it's due to some other python application running or something, but when I was a beginner in Flask I got a similar error to you.
I wrote app.route('/') instead of @app.route('/') (I missed the @ symbol).
See whether it's the case for your code.
My solution to this problem: is to switch this instruction
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
as in the example bellow
from flask import Flask, render_template, request
app = Flask(__name__,template_folder="template")
@app.route("/")
def hello():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
@app.route('/register', methods=['POST'])
def register():
query = request.form.get('query1')
selected = request.form.get('query')
if (not query or not selected):
return 'failure'
processed_text = query.upper()
return render_template('sucess.html')
to the end of your script (same example):
from flask import Flask, render_template, request
app = Flask(__name__,template_folder="template")
@app.route("/")
def hello():
return render_template('index.html')
@app.route('/register', methods=['POST'])
def register():
query = request.form.get('query1')
selected = request.form.get('query')
if (not query or not selected):
return 'failure'
processed_text = query.upper()
return render_template('sucess.html')
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
UPDATE---------------------------------
You should also take care of the local file. Please put them in the statistic field then use url_for from the Flask framework to create a correct URL
<div style = "text-align: center;">
<a href="{{ url_for('static',filename=path)}}">
<button class="slide_from_bottom button">check here </button>
</a>
</div>
I initially tried with @app.route("/hello") where the function I defined inside was def hello(): return "some statement" this gave me the error stated above, I removed "/hello" and tried with "/" this resolved the issue for me. p.s(I did this in pycharm and os is windows 10)
I had this issue after deploying a legacy Python Flask application to Azure App Service for my team.
I was getting the error:
Not Found. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Here's how I fixed it:
The issue was that the URL I was entering wasn't the right one. Apparently, the developers did not set a root route, so instead of this:
https://my-website.com
You will have to specify the path to the resource you want, so we will have:
https://my-website.com/my-desired-path
That's all