Skip to main content
  1. Posts/

Collecting-data-from-a-leaflet-map-with-flask-St

149 words·1 min

Collecting-data-from-a-leaflet-map-with-flask-St #

Collecting data from a leaflet map with flask - Stack Overflow #

Created: February 27, 2020 2:27 PM URL: https://stackoverflow.com/questions/52172010/collecting-data-from-a-leaflet-map-with-flask ! apple-touch-icon@2.png I’m trying to create a webpage with flask. The webpage includes a leaflet map where I can click on the map to create a marker which opens a popup window with a link. The link is supposed to open a new page where I can see the longitude and latitude. I’m currently struggeling on how to send the leaflet coordinates from my js to flask and then to the second route. Can someone explain to me what I’m doing wrong? Python file:

from flask import Flask, render_template, url_for, request, redirect
app = Flask(__name__)
@app.route('/', methods=["GET","POST"])
def mainpage():
if request.method == "POST":
longitude = request.form["longitude"]
latitude = request.form["latitude"]
return lredirect(url_for("form", longitude=longitude, latitude=latitude))
return render_template("main.html")
@app.route('/form')
def form():
return render_template("form.html")
if __name__ == "__main__":
app.run(debug=True)

main.html file: