title: How can I search in mongodb using an html page with button and using flask with python?
body: <p>Hi I'm new to both flask and html.
  I have a database that contains a collection of documents (representing road routes) that have the following structure:
  <a href="https://i.stack.imgur.com/jooZs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jooZs.png" alt="Document structure"></a></p>
  
  <p>I would like to be able to query my mongodb via a html page structured like this:
  <a href="https://i.stack.imgur.com/IS0JM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IS0JM.png" alt="Html page"></a></p>
  
  <p>Where in the first field I enter (Lat1, Long1) of my position in the second field insert (Lat2, Long2) of my destination and through the search button if it is present in the database print it below on the page otherwise it will tell me "route not present".</p>
  
  <p>My simple and trivial index.html where I create the buttons is as follows:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
   &lt;h1&gt;Choose your route:&lt;/h1&gt;
   &lt;form action="/list" method="get" autocomplete="on"&gt;
   &lt;td&gt;&lt;input type="text" name="key" placeholder="Your Position" size="20" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type="text" name="key" placeholder="Search Destination" size="20" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;button type="submit"&gt;Search&lt;/button&gt;&lt;/td&gt;
   &lt;button type="Reset" value="Reset"&gt;Reset&lt;/button&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>While the python code with flash is the following:</p>
  
  <pre><code>@app.route("/list")
  def lists ():
  #Display the all Task
  return render_template('index.html',h=heading)
  
  @app.route("/search", methods=['GET'])
  def search():
  #Searching a Task with various references
  Lat1=request.values.get("Lat1")
  Long1=request.values.get("Long1")
  Lat2=request.values.get("Lat2")
  Long=request.values.get("Long2")
  refer=request.values.get("refer")
  #I make the comparison to understand if the route is present in the 
  database.
  if(Lat1 == "Lat1" and Long1 == "Long1" and Lat2 == "Lat2" and Long2 == 
  "Long2"):
      test_l = tests.find({Lat1:ObjectId(Lat1)})
      test_l = tests.find({Long1:ObjectId(Long1)})
      test_l = tests.find({Lat2:ObjectId(Lat2)})
      test_l = tests.find({Long2:ObjectId(Long2)})
  else:
      print("Route not present")
  return 
  render_template('searchlist.html',tests=test_l,t=title,h=heading)
  </code></pre>
  
  <p>The searchlist.html page I did not know how to structure it.
  So my problem is to create the searchlist.html page and change the python code in flask to be able to search.
  Thank you so much.</p>