命名主要在我的谷歌App Engine應用程序,打算到URL /foo
時,我得到的錯誤導入錯誤 - 沒有模塊GAE
ImportError: No module named main
。我應用程序中的所有文件都在父目錄中。
這是我app.yaml
:
application: foobar
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /foo.*
script: main.application
- url:/
static_files: index.html
- url: /(.*\.(html|css|js|gif|jpg|png|ico))
static_files: \1
upload: .*
expiration: "1d"
這裏是我的main.py
:
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
class Handler(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello world!')
def main():
application = webapp.WSGIApplication([('/foo', Handler)],
debug=False)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
我得到同樣的錯誤當我改變main.application
到main.py
或只是main
。爲什麼會發生此錯誤?
謝謝,我應該使用webapp2。但是,它仍然不起作用。 [hello world example](https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld)正常工作;當python腳本不是主要的請求處理程序時(即只爲'/ foo。*') –
請解釋。你是什麼意思:「當python腳本不是主要的請求處理程序」 – voscausa
因爲它只處理以'/ foo'開始的URL,而不是基本URL'/'。 –