【发布时间】:2013-02-28 06:53:50
【问题描述】:
我正在尝试将不同的 url 映射到不同的 python 脚本。
这是我的 yaml
application: myApp
version: 99
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /deleteCustomers
script: test.app
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
builtins:
- remote_api: on
如果我转到http://myapp.appspot.com/test,它会显示“404 未找到”... 如果我去http://myapp.appspot.com,就会启动正确的脚本(main.app)
我遇到了同样的问题 -> HERE 但给定的解决方案对我不起作用(即使它是相同的代码!!!)
这是处理程序(为了测试“2 路径 yaml”,我复制了 main.app,它包含客户和商店类以及 mainhandler,将其重命名为 test.app。所以 main.app 和 test.app 都是相同)
class MainHandler(webapp2.RequestHandler):
def get(self):
customers = Customers.all()
stores = Stores.all()
countCustomers= 0
countStores= 0
for p in customers:
p.delete()
countCustomers+= 1
for p in stores:
p.delete()
countStores+= 1
self.response.out.write("\nDeleted Customers: " + str(countCustomers))
self.response.out.write("\nDeleted Stores: " + str(countStores))
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
我想要实现的是将客户和商店删除拆分为两个单独的调用:
http://www.myapp.appspot.com/deleteCustomers 和 http://www.myapp.appspot.com/deleteStores
提前感谢您的帮助,最好的问候
【问题讨论】:
-
试试这个:url:/test.* 你也可以发布处理程序和路由到测试处理程序的路由器。
-
你能把代码贴在测试应用中吗?
标签: python web-services google-app-engine http-status-code-404