I have 2 pages , they are search and results, i want to get data from search and display in Results i'm trying to pass through URL but i'm not able to find the solution for it
@views.route('/search',methods=["GET","POST"])
def search():
if request.method == "POST":
city_name = request.form['city_name']
return redirect(url_for("results",city_name=city_name))
return render_template("search.html")
@views.route('/results/<city_name>')
def results(city_name):
geolocator = Nominatim(user_agent="MyApp")
location = geolocator.geocode("Hyderabad")
latitude= location.latitude
longitude= location.longitude
t = time.localtime()
current_time = time.strftime("%I:%M", t)
today = date.today()
d4 = today.strftime("%b-%d-%Y")
HTML_current_time = str(current_time) + " " + str(d4)
return render_template("results.html", current_time=HTML_current_time,latitude=latitude,longitude=longitude,city_name=city_name)
the search page form
<form action="{{ url_for('views.results',city_name=city_name) }} " method="post">
<input type="text" name="text" id="search" placeholder="Enter the place area...">
<button type="submit" class="btn"> <img src="/static/images/search.png" alt=""></button>
</form>