1

I have

class Auth(webapp.RequestHandler):
    def get(self,username,password):
        self.response.out.write("auth" + self.request.get("username"))

The structure of my URL will be:

/api/auth/?username=xxxx&password=xxxx

How do I map this URL in my handler script?

1
  • 1
    Any chance you can use a POST instead? Passwords in GETs are not best practice. (Extra credit: use something better than plain passwords across the wire) Commented Apr 24, 2011 at 22:46

1 Answer 1

4

Handler:

class Auth(webapp.RequestHandler):
    def get(self):
        self.response.out.write("username" + self.request.get("username"))
        self.response.out.write("password" + self.request.get("password"))

Url:

/api/auth?username=xxxx&password=xxxx

Application:

application = webapp.WSGIApplication([
    ('/api/auth', Auth),
    ], debug=True)
Sign up to request clarification or add additional context in comments.

2 Comments

Not sure why yours didn't work but I got this to work (/api/auth/(.*)(.*)',Auth)
@jwesonga That only works because (.*) matches the empty string, and you have two additional parameters 'username' and 'password'. Remove those parameters from your handler - you have to use self.request.get to get the query string arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.