我試圖將不同的網址映射到不同的python腳本。gae&python - 在yaml中設置不同的網址:404找不到
這是我的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.*你也可以發佈處理程序和路由到測試處理器的路由器。 – Tkingovr 2013-03-12 16:42:07
它不起作用:| – BeNdErR 2013-03-12 16:45:03
你可以在測試應用中發佈代碼嗎? – Tkingovr 2013-03-12 16:46:31