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 8171755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:33:29+00:00 2026-06-06T21:33:29+00:00

okay so this seemed like it should be pretty basic but I just can’t

  • 0

okay so this seemed like it should be pretty basic but I just can’t get it to work. I am getting a 404 error saying that the resource cannot be located, though I am being directed to the correct address, http://www.url.com/sea?s=’1′ for sailing for example. I have a list of links with different query parameters and I want them to be handled differently by my python code. I am using google app engine with python and a jinja2 template system.

Here is my HTML:

  <h3><a href="/" class="center-it">Quick Navigation</a></h3>
    <div class="span1">
    <div class="span1">
      <h4><a href="/sea">Sea</a></h4>
        <ul>
            <li><a href="/sea?s='1'">Sailing</a></li>
            <li><a href="/sea?s='2'">Diving</a></li>
            <li><a href="/sea?s='3'">Surfing</a></li>
            <li><a href="/sea?s='4'">Kite Boarding</a></li>
            <li><a href="/sea?s='5'">Kayaking</a></li>
        </ul>
   </div>

and here is the python:

class Sea(BlogHandler):
    def get(self, s):
        s = self.request.get('s')
        if s == '1':
            posts = posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", "sailing")
        elif s == '2':
            posts = posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", "diving")
        elif s == '3':
            posts = posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", "surfing")
        elif s == '4':
            posts = posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", "kiteboarding")
        elif s == '5':
            posts = posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", "kayaking")
        else:
            posts = posts = db.GqlQuery("select * from Post where element=:1 order by created desc limit 30", "sea")

        global visits
        user = users.get_current_user()
        logout = users.create_logout_url(self.request.uri)        
        self.render('sport.html', user = user, posts=posts, visits = visits, logout=logout)

UPDATE:
The problem wasn’t actually with the code it was with my URL handling. This is correct:

app = webapp2.WSGIApplication([('/', MainPage),
                               (r'/sea', Sea)]
  • 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-06-06T21:33:31+00:00Added an answer on June 6, 2026 at 9:33 pm

    The 404 error is coming on not because of anything wrong in your page, but rather because something is wrong with your routes or your app.yaml file. If you are using webapp2, you just need to define a route that has the url r'/air' and it should work. (e.g. webapp2.Route(r'/sea/', handler=Sea)

    By the way, instead of using query strings in your get request, you could put those in as route kwargs and do nicer things, e.g. (the syntax is <KEYWORDNAME:REGULAREXPRESSION> when no keyword name is given (like in <:/?>) it just matches the regex and doesn’t pass anything through to you)

    webapp2.Route(r'/sea<:/?><activity:[a-zA-Z]*?>', defaults={"activity":""}, handler=Sea, name="sea")
    

    And then you could change your urls to, for example:

    <a href="/sea/sailing">Sailing</a>
    

    The only other change you need to make is in your Handler function. It needs to accept kwargs. (so you can literally just change your get request slightly):

    get(self, *args, **kwargs):
        activity = kwargs.get("activity")
        if activity in ("sailing", "kayaking", "hiking", "kiteboarding", "surfing", "diving")
           posts = db.GqlQuery("select * from Post where sport=:1 order by created desc limit 30", activity)
        elif activity:
           self.error(404)
        else:
           posts = db.GqlQuery ... etc
    

    Which would simplify your code quite a bit and let you make it more flexible. Further, if your site doesn’t update very often, you could do a bit of caching to make the queries snappier, etc.

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

Sidebar

Related Questions

okay this might be a pretty lame and basic question but its stuck in
I'm sure this is fairly straightforward but i'm having trouble getting it to work.
Okay this is definitely a n00b question but here goes. The way I understand
Okay this is definitley an easy question and a stupid one but since I
Okay this may be a simple question but I have yet to come with
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
Okay this is werid, i keep getting the error, randomly. ValueError: matrix must be
Okay this is very hard to explain, but i want to add padding to
Okay, so i'm pretty new to C++ & the Windows API and i'm just
Okay this one may be a bit out from left field, but I'm going

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.