gpt4 book ai didi

python - 应用程序适用于本地主机但不适用于 appspot

转载 作者:太空宇宙 更新时间:2023-11-04 06:28:27 25 4
gpt4 key购买 nike

我正在努力让用户使用 Foursquare 在我的网页上进行身份验证,一旦他们被重定向回我的网页,收到的信息就会从 URL 中解析出来。这在本地主机上运行完美,但是当我部署它时,出现以下错误

    Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 634, in __call__
handler.get(*groups)
File "/base/data/home/apps/hoosheer/4.349803081119561985/hoosheer_main.py", line 34, in get
foursquareMethods.foursquareDetails(self)
File "/base/data/home/apps/hoosheer/4.349803081119561985/foursquareMethods.py", line 40, in foursquareDetails
doRender(self, '500.html')
File "/base/data/home/apps/hoosheer/4.349803081119561985/foursquareMethods.py", line 67, in doRender
handler.response.out.write(template.render(path, template_values))
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 72, in render
t = load(template_path, debug)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 100, in load
template = django.template.loader.get_template(file_name)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 80, in get_template
template = get_template_from_string(source, origin, template_name)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 88, in get_template_from_string
return Template(source, origin, name)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 158, in __init__
self.nodelist = compile_string(template_string, origin)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 174, in compile_string
return parser.parse()
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 273, in parse
compiled_result = compile_func(self, token)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader_tags.py", line 154, in do_extends
nodelist = parser.parse()
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 273, in parse
compiled_result = compile_func(self, token)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader_tags.py", line 132, in do_block
nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 280, in parse
self.unclosed_block_tag(parse_until)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 318, in unclosed_block_tag
raise self.error(None, "Unclosed tags: %s " % ', '.join(parse_until))
TemplateSyntaxError: Unclosed tags: endblock, endblock bodycontent

更新

当我尝试 doRender(self, '500.html') 时,我的代码中的那一行似乎导致了它
这是 doRender 方法

def doRender(handler, tname, values = { }):    
template_values = dict(values)
handler.session = Session()
if 'access_token' in handler.session:
template_values['access_token'] = handler.session['access_token']
path = os.path.join(os.path.dirname(__file__), tname)
handler.response.out.write(template.render(path, template_values))

模板如下

{% extends "index.html" %} 
{% block bodycontent %}
Server Error
<p>
There has been an error
</p>
{% endblock %}

最佳答案

您的 app.yaml 文件中是否设置了“/_ah/login_required”处理程序?

我假设您已打开联合登录以允许使用 Foursquare 凭据。如果是这样,您需要定义自己的登录处理程序,以便它在 appspot 上工作(本地主机使用不同的登录处理)。

例如:

handlers:
- url: /_ah/login_required
script: do_openid_login.py

关于python - 应用程序适用于本地主机但不适用于 appspot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5688216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com