Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 404使用google app engine创建唯一页面时出错_Python_Google App Engine_Url Mapping - Fatal编程技术网

Python 404使用google app engine创建唯一页面时出错

Python 404使用google app engine创建唯一页面时出错,python,google-app-engine,url-mapping,Python,Google App Engine,Url Mapping,我在这里问了一个类似的问题:但不能完全得到答案。我试图给我的网站上的每个用户一个独特的个人资料页。我基本上已经设置好了,但我一直收到404错误。现在我不确定这是否是我的教练的问题,或者只是我做这件事的整个过程 以下是我的应用程序代码: app = webapp2.WSGIApplication([('/', MainPage), (r'/profile/(.+)', ProfilePage)]) 下面是我的ProfilePage处理

我在这里问了一个类似的问题:但不能完全得到答案。我试图给我的网站上的每个用户一个独特的个人资料页。我基本上已经设置好了,但我一直收到404错误。现在我不确定这是否是我的教练的问题,或者只是我做这件事的整个过程

以下是我的应用程序代码:

app = webapp2.WSGIApplication([('/', MainPage),
                               (r'/profile/(.+)', ProfilePage)])
下面是我的ProfilePage处理程序类:

class ProfilePage(webapp2.RequestHandler):
    def get(self, profile_id):
        profileowner = User.get_by_id(profile_id)

        if profileowner:
            #Get all posts for that user and render....
            #theid is their federated_id 
            theid = profileowner.theid
            personalposts = db.GqlQuery("select * from Post where theid =:1 order by created desc limit 30", theid)

            #I collect this so that I can have their username in the top of the page
            global visits
            logout = users.create_logout_url(self.request.uri)
            currentuser = users.get_current_user()
            self.render('profile.html', user = currentuser, visits = visits, logout=logout, personalposts=personalposts)
        else:
            self.redirect("/")
对于我在datastore viewer中找到的用于使用的ID 1201,我一直在通过键入www.url.com/profile/1201对其进行测试,这就是我得到404错误的时候

更新: 它现在将我重定向到带有Amber建议更改的主页

现在,当我更改这一行时:

profileowner = User.get_by_id(profile_id)
为此:

profileowner = User.get_by_id(17001)

它正确地通过了,所以我猜这一行没有正确地从URL获取配置文件id,然后它将我重定向到(“/”)好的,这意味着您提供了一个无效的id。您试图访问哪个URL?您是否尝试将id转换为整数?以及我从我的app engine dataviewer中获得的17001的名称/id列。我刚刚用更多信息更新了这个问题。试着放一个
int()
查看
配置文件id
,看看这是否有帮助。
r'/profile/<profile_id>'
r'/profile/(.+)'