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

  • Home
  • SEARCH
  • 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 8269319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:11:13+00:00 2026-06-08T06:11:13+00:00

I have been trying to get the request url as follows import webapp2 class

  • 0

I have been trying to get the request url as follows

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        print self.request.get('url')

app = webapp2.WSGIApplication([('/.*', MainPage)], debug=True)

when the request is

http://localhost:8080/index.html

it gives me something like

Status: 200 Content-Type: text/html; charset=utf-8 Cache-Control: no-cache Content-Length: 70

what I need to get is something like

index.html

edit: so that I can check the string and display the correct html/template file accordingly.

I have already checked Request documentation and tried many alternatives yet I can’t seem to find a solution. I’m quite new to web development. What am I missing?

  • 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-08T06:11:15+00:00Added an answer on June 8, 2026 at 6:11 am

    you should start here: https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld

    you are not using a template or a templating module/engine so its irrelevant what path you are accessing because you are mapping everything with /.*

    use self.response.write() not print.
    again its better for you if you start reading the documentation from the beginning before checking out the request class.

    EDIT:

    if you want to get the urlpath in the requesthandler and serve different templates based on the urlpath then do something like this:

    def get(self):
        if self.request.path == '/foo':
            # here i write something out
            # but you would serve a template
            self.response.write('urlpath is /foo')
        elif self.request.path == '/bar':
            self.response.write('urlpath is /bar')
        else:
            self.response.write('urlpath is %s' %self.request.path)
    

    a better approach would be to have multiple ReqeustHandlers and map them in the WSGIApplication:

    app = webapp2.WSGIApplication([('/', MainPage),
                                   ('/foo', FooHandler),
                                   ('/bar', BarHandler),
                                   ('/.*', CatchEverythingElseHandler)], debug=True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to get LastBootUpTime using Win32_OperatingSystem class (WMI). HRESULT hr =
I have been trying to get a simple xhr request to work but for
I have been trying to get my Arduino/Eclipse environment setup. For some reason I
I have been trying to get a handle on using MVC 4.0 with EF
I have been trying to get Twitter Bootstrap btn-group with dropdown to work for
I have been trying to get tsung to connect to a box I have
I have been trying to get a custom Value from the Custom Field that
I have been trying to get a PNG to upload with a clean, 24
I have been trying to get yui-css grid system to make a three column
I have been trying to get nServiceBus to work with Ninject 2.0 as the

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.