GAE python中的YAML文件url和脚本
我在Google App Engine中使用Python 2.7,似乎无法正确设置App.yaml文件 我的目标是,如果我转到GAE python中的YAML文件url和脚本,python,google-app-engine,yaml,Python,Google App Engine,Yaml,我在Google App Engine中使用Python 2.7,似乎无法正确设置App.yaml文件 我的目标是,如果我转到http://localhost/carlos/我得到一个执行的carlos.py 以下是我的目录结构: app\ \app.yaml \main.py \carlos.py 以下是我当前的app.yaml文件: application: myapp version: 1 runtime: python27 api_version: 1 threads
http://localhost/carlos/
我得到一个执行的carlos.py
以下是我的目录结构:
app\
\app.yaml
\main.py
\carlos.py
以下是我当前的app.yaml文件:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /carlos/.*
script: carlos.app
- url: .*
script: main.app
我的carlos.py文件是:
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, Carlos!")
app = webapp2.WSGIApplication([('/carlos', MainHandler)],
debug=True)
然而,我现在得到的只是一个404未找到错误。有什么想法吗?它通过以下修改工作: 1-在yaml文件中将“carlos.app”替换为“carlos.py”,将“main.app”替换为“main.py” 2-在文件“carlos.py”中的“/carlos”之后添加斜杠(“/”) 3-在每个python文件(carlos.py和main.py)的末尾添加以下部分代码
以下是修改文件的示例: app.yaml:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /carlos/.*
script: carlos.py
- url: .*
script: main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, MAIN!")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
def main():
app.run()
carlos.py:
导入webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, Carlos!")
app = webapp2.WSGIApplication([('/carlos/', MainHandler)],
debug=True)
def main():
app.run()
main.py:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /carlos/.*
script: carlos.py
- url: .*
script: main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, MAIN!")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
def main():
app.run()
您可以尝试导航到:
localhost:8080/carlos/和localhost:8080/以查看结果
希望有帮助;) 它通过以下修改工作: 1-在yaml文件中将“carlos.app”替换为“carlos.py”,将“main.app”替换为“main.py” 2-在文件“carlos.py”中的“/carlos”之后添加斜杠(“/”) 3-在每个python文件(carlos.py和main.py)的末尾添加以下部分代码
以下是修改文件的示例: app.yaml:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /carlos/.*
script: carlos.py
- url: .*
script: main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, MAIN!")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
def main():
app.run()
carlos.py:
导入webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, Carlos!")
app = webapp2.WSGIApplication([('/carlos/', MainHandler)],
debug=True)
def main():
app.run()
main.py:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /carlos/.*
script: carlos.py
- url: .*
script: main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hello, MAIN!")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
def main():
app.run()
您可以尝试导航到:
localhost:8080/carlos/和localhost:8080/以查看结果
希望有帮助;) 我能够确定解决方案,我想我会为任何人发布它 在我的carlos.py文件中,我需要替换:
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
与
WSGIApplication的第一个参数似乎是指根web地址的总路径,而不是最初指向它的增量路径
我之所以选择这个答案,是因为我想继续使用WSGI,因为我能够确定解决方案,并且我想我会为那里的任何人发布它 在我的carlos.py文件中,我需要替换:
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
与
WSGIApplication的第一个参数似乎是指根web地址的总路径,而不是最初指向它的增量路径
我之所以选择这个答案,是因为我想继续使用WSGI,而不是Littm提供的答案