YAML file url and script in GAE python(GAE python中的YAML文件url和脚本)
问题描述
我在 Google App Engine 中使用 Python 2.7,但似乎无法正确设置我的 app.yaml 文件.
I'm using Python 2.7 in Google App Engine and can't seem to get my app.yaml file set up right.
我的目标是,如果我去 http://localhost/carlos/
我会得到一个已执行的 carlos.py
My goal is so that if I go to http://localhost/carlos/
I get an executed carlos.py
这是我的目录结构:
app
app.yaml
main.py
carlos.py
这是我当前的 app.yaml 文件:
Here is my current app.yaml file:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /carlos/.*
script: carlos.app
- url: .*
script: main.app
我的 carlos.py 文件是:
and my carlos.py file is:
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, Carlos!")
app = webapp2.WSGIApplication([('/carlos', MainHandler)],
debug=True)
但是我现在得到的只是 404 Not Found 错误.有什么想法吗?
However all I'm getting now is a 404 Not Found error. Any thoughts?
推荐答案
我能够确定解决方案并想把它发布给那里的任何人.
I was able to determine the solution and figured I'd post it for anyone out there.
在我需要替换的 carlos.py 文件中:
In my carlos.py file I needed to replace:
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
与
app = webapp2.WSGIApplication([('/carlos/', MainHandler)],
debug=True)
似乎 WSGIApplication 的第一个参数是指从您的根网址开始的 TOTAL 路径,而不是最初指向它的 INCREMENTAL 路径.
It appears that the first argument for the WSGIApplication is referring to the TOTAL path from your root web address as opposed to the INCREMENTAL path from which it was originally directed.
我选择这个答案而不是 Littm 提供的答案,因为我想继续使用 WSGI
I'm selecting this answer over what was provided by Littm because I'd like to keep using WSGI
这篇关于GAE python中的YAML文件url和脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:GAE python中的YAML文件url和脚本


基础教程推荐
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01