When I ran the code, when I submit on the /about page i am getting :
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
from flask import Flask, render_template,redirect,request
#name==main
app=Flask(name)
friends=[‘Harshit’, ‘Udit’, ‘Jayesh’]
@app.route(’/’)
def hello():
return(“Hello World…”)
@app.route(’/about’)
def about():
return render_template(“index.html”,my_friends=friends)
@app.route(’/home’)
def home():
return redirect(’/’)
@app.route(’/submit’ methods=[‘POST’]) # by default methods is get and you cant send post request from url bar post can only be sent through html or python
def submit_data():
# if request.method==‘POST’:
# name=request.form[“username”]
name = “Udit”
return "
Hello {}".format(name)
if name==‘main’:
#app.debug=True
app.run(debug=True)
HTML Code:
Home Page
The flask page
{% for f in my_friends %}