我剛剛開始使用谷歌應用引擎,並且我在谷歌應用引擎上遵循了基本的Hello World例子。谷歌應用引擎dev_appserver.py問題
https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld
中的HelloWorld文件夾中創建兩個文件。
我不想使用GUI我更喜歡使用mac終端來處理這個應用程序。我想通過終端在本地主機localhost:80上啓動這個應用程序。
運行我的基本的HelloWorld應用程序在本地所有我要說的是
$ dev_appserver.py的HelloWorld。但我得到這個錯誤。
Traceback (most recent call last):
File "/usr/local/bin/dev_appserver.py", line 184, in <module>
_run_file(__file__, globals())
File "/usr/local/bin/dev_appserver.py", line 180, in _run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 727, in <module>
main()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 720, in main
dev_server.start(options)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 554, in start
options.yaml_files)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
module_configuration = ModuleConfiguration(yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
self._yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 271, in _parse_configuration
with open(configuration_path) as f:
IOError: [Errno 2] No such file or directory: 'helloworld'
我在helloworld目錄中有兩個文件。 的app.yaml
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.application
和helloworld.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
錯誤說沒有文件或目錄。 helloworld目錄是否存在於您運行該命令的目錄中,並且是否有app.yaml? –
事實上,我更新了我的文章,其中包含兩個文件。在運行dev_appserver.py之前,我確保cd進入目錄,但仍然不行。 – muhammed
如果你進入'helloworld'目錄,那麼這個命令應該是'dev_appserver.py .'這個參數是一個包含app.yaml的目錄的路徑。如果你在那個目錄下,那麼路徑就是當前目錄或'.'的完整路徑 –