GAE python中的YAML文件url和脚本

YAML file url and script in GAE python(GAE python中的YAML文件url和脚本)
本文介绍了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和脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)