Python 3.x 应用程序引擎:如何为烧瓶应用程序配置App.yaml?错误:找不到index.html
我已经使用Python 3.7构建了一个Flask应用程序。该设置在本地工作。当上传到GAE时,我得到一个内部服务器错误。GAE仪表板显示未找到Python 3.x 应用程序引擎:如何为烧瓶应用程序配置App.yaml?错误:找不到index.html,python-3.x,google-app-engine,flask,app.yaml,Python 3.x,Google App Engine,Flask,App.yaml,我已经使用Python 3.7构建了一个Flask应用程序。该设置在本地工作。当上传到GAE时,我得到一个内部服务器错误。GAE仪表板显示未找到index.html。此问题是否与app.yaml文件有关 我的项目结构如下: root/ |-app.yaml |-requirements.txt |-main.py |-other model files that feed into main.py |-templates/ |-index.html |-index2.html
index.html
。此问题是否与app.yaml
文件有关
我的项目结构如下:
root/
|-app.yaml
|-requirements.txt
|-main.py
|-other model files that feed into main.py
|-templates/
|-index.html
|-index2.html
|-js
|-css
|-images
app.yaml
App Engine文档说明:
模式按照它们在app.yaml
文件中出现的顺序从上到下进行评估。模式与URL匹配的第一个映射是用于处理请求的映射
- 将catch all处理程序放在末尾
目录不需要添加到URL处理程序中模板
- 按照惯例,
目录应为小写。此外,如果URL处理程序确实需要引用模板
,则模板
模式是区分大小写的(如所述),使用小写将有助于避免不匹配app.yaml
- 标准设置是在
目录旁边创建一个单独的模板
(和/或静态
)目录。资产
目录将包含Javascript、CSS和图像等文件static
谢谢你的建议。我试过了,但还是犯了同样的错误。下面是调试器的屏幕截图(如果有帮助的话)@SangyH Answer更新了标准项目设置。烧瓶模板不需要显式URL处理程序。谢谢!!!成功了。我首先更新了标准项目设置。我仍然有index.html未找到的问题。然后我看到了Dan Cornilescu关于模板与模板之间的关系的评论。然后,我重新开始并创建了一个新的应用程序,这次是一个名为templates的文件夹,它最终成功了。我建议在这个答案中也加入关于“templates”大写的行为作为旁注。@DanCornilescu将其作为评论记录在原始帖子中。@JKleinne感谢您的留言。由于
app.yaml
区分大小写,答案更新为在小写的templates
文件夹中包含DanCornilescu的注释。旁注:app.yaml
模式区分大小写,您在帖子中同时使用了templates
和templates
。当然,你的IDE图片显示的只是文章内容。谢谢Dan。我相信这是问题的一部分。它现在起作用了。
runtime: python37
# [START handlers]
handlers:
- url: /.*
script: auto
- url: /index.html
static_files: templates/index.html
upload: Templates/index.html
- url: /templates
static_dir: Templates
- url: /(.*\.(css|js|png|jpg))
static_files: templates/\1
upload: templates/(.*)
# [END handlers]
root/
|-app.yaml
|-requirements.txt
|-main.py
|-other model files that feed into main.py
|-static/
|-js
|-css
|-images
|-templates/
|-index.html
|-index2.html
runtime: python37
handlers:
- url: /static
static_dir: static
- url: /.*
script: auto