Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.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
GAE python中的YAML文件url和脚本_Python_Google App Engine_Yaml - Fatal编程技术网

GAE python中的YAML文件url和脚本

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

我在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
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提供的答案