תומר לב
תומר לב

Reputation: 3

The forward slashes are ignored in the local environment but not in the global environment

I'm writing an app in my google app engine which get 2 parameters and write the first one to the app if the user is an admin and the second otherwise:

The app works like that:

import webapp2
import webapp2
from google.appengine.api import users

class ShowPara(webapp2.RequestHandler):
    def get(self,para1,para2):
        user = users.get_current_user()
        if users.is_current_user_admin():
            message_text = para1
        else:
            message_text = para2
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write(message_text)

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

When I run this app on the local google app engine launcher with the following URL:

localhost:25080///////////////////a/b

I'm getting the following result:

//////////////////a

When I run the exact same app after deploying it on google servers with the following URL (same one):

https://hw01-2020.appspot.com///////////////////a/b

I'm getting the following result:

a

It's important to note that I'm forcing login in my YAML file by the follwong code:

login: required

Why when I run it locally it won't ignore the slashes and when I run it after deploy it it is?

Upvotes: 0

Views: 37

Answers (1)

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

Some servers automatically collapse multiple consecutive / chars into a single one. Even SO: The forward slashes are ignored in the local environment but not in the global environment. It's possible that GAE's frontent does the same.

You could adjust your pattern to account for that and always get the parameters without the '/' char in them:

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

Upvotes: 1

Related Questions