Andrés AG
Andrés AG

Reputation: 419

server cannot match URL with handler (HTTP 404 error)

I am working on some python code that is meant to run in Google App Engine. In one of the handlers I am trying to get some data that was sent through post using a form like this:

<form action="/search" method="GET" enctype="multipart/form-data">
    <fieldset>
        <legend>File Search</legend>
        Search Tag:</br>
        <input type="text" name="search_text"></br>
        <input type="submit" value="Search">
    </fieldset>
</form>

So when the user presses the search button the URL looks something like this:

localhost:8080/search?search_text=ico

The problem is that when the browser is redirected there I always get a 404 error. I think the problem is that for some reason GAE cannot match the URL to the list of (URL, handler) pairs in my app variable. It looks like this:

app = webapp2.WSGIApplication([... ('/search([^/]+)', SearchHandler) ...], debug=True)

I really dont know why this is the case because when I try the pattern in the python command line interpreter and it works:

>>> import re
>>> pat = "/search([^/]+)"
>>> t = "/search?search_text=ico"
>>> print re.match(pat, t)
<_sre.SRE_Match object at 0x01E449E0>

I think it has something to do with the '?' character, however I tried matching it using something like '\?' in the pattern and it doesnt work. Help would be very appreciated, Thanks! I also wanted to point out that I am a beginner with GAE...

Upvotes: 0

Views: 99

Answers (1)

Greg
Greg

Reputation: 10360

You should only be attempting to match the path part of the URL - not including the query part (the ? and everything after it). '/search' as your pattern will be sufficient.

Upvotes: 1

Related Questions