Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7027455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:15:00+00:00 2026-05-28T00:15:00+00:00

In Flask you write the route above the method declaration like so: @app.route(‘/search/<location>/’) def

  • 0

In Flask you write the route above the method declaration like so:

@app.route('/search/<location>/')
def search():
  return render_template('search.html')

However in HTML the form will post to the url in this fashion:

www.myapp.com/search?location=paris

The latter seems to return a 404 from the application where

www.myapp.com/search/london

will return as expected.

I’m sure that there is a simple piece of the puzzle that I’m not getting, but surely the routing engine will consider the query string parameters for meeting the rules requirements.

If not, what is the optimal solution for this scenario as I’m sure 90% of developers must arrive at this point.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:15:01+00:00Added an answer on May 28, 2026 at 12:15 am

    The query parameters are not included as part of the route matching, nor are they injected into function arguments. Only the matched URL portions are injected. What you’re looking for is request.args (GET query parameters), request.form (POST) or request.values (combined).

    You could do something like this if you wanted to support both:

    @app.route('/search/<location>')
    def search(location=None):
        location = location or request.args.get('location')
        # perform search
    

    Though, assuming you may want to search on other parameters, probably the best way to do it would be closer to:

    def _search(location=None,other_param=None):
        # perform search
    
    @app.route('/search')
    def search_custom():
        location = request.args.get('location')
        # ... get other params too ...
        return _search(location=location, other params ... )
    
    @app.route('/search/<location>')
    def search_location(location):
        return _search(location=location)
    

    And so forth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been wanting to learn to write a Flash app so that it
I'm writing an application with Flask and I'd like to generate different code for
I need to write a small Flash app that will need to extract a
I want to write a Flash applet(or any other possible app) to embed in
I'm using elixir/flask in a small web app I wrote for my own personal
I'm trying to write an API for a website, whose Flash app gets data
I'd like to write a little class that adds a Day/Month box showing the
I have been developing an app using the very easy-to-pickup Flask system and I
I am developing web app on flask, python, sqlalchemy and postgresql. My question is
I have a Python Flask app I'm writing, and I'm about to start on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.