Reputation: 95
i have been working on GAE - tried to create a new project: and getting an error on command
abid@abid-webdev:~/Documents/GAE_projects$ python google_appengine/dev_appserver.py exe1.py/
ERROR
INFO 2013-10-29 08:27:57,104 module.py:608] default: "GET / HTTP/1.1" 500 - ERROR 2013-10-29 08:29:43,171 wsgi.py:262] Traceback (most recent call last): File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler handler, path, err = LoadObject(self._handler) File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject obj = import(path[0]) ImportError: No module named helloworld INFO 2013-10-29 08:29:43,191 module.py:608] default: "GET / HTTP/1.1" 500 - ERROR 2013-10-29 08:29:51,775 wsgi.py:262] Traceback (most recent call last): File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler handler, path, err = LoadObject(self._handler) File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject obj = import(path[0]) ImportError: No module named helloworld
1) ImportError: No module named helloworld
-> i noticed this error
currently working on this project exercise1
, copied app.yaml file from previous project helloworld/
checked app.yaml and it's content are as follows:
application: your-app-id version: 1 runtime: python27 api_version: 1 threadsafe: true
handlers: - url: /.*
script: helloworld.application>
2) on google URL -> Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the application object in the helloworld module.
3) my directory structure
abid@abid-webdev:~/Documents/GAE_projects$ ls
exercise1
helloworld
google_appengine
Question:
how can i modify my app.yaml to work with my other projects e.g. exercise1?
thanks all for your help.
Upvotes: 0
Views: 331
Reputation: 1038
Let's take this from the top!
For your new project you will need to have this structure in the exercise1 directory:
Directory: exercise1
File: app.yaml
File: exercise1.py
In the app.yaml you'll need something like this:
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: exercise1.application
The line "script: exercise1.application" tells it which file to use (in this case exercise1.py) and the instance of a WSGI Handler to use (in this case application)
In exercise1.py you'll need something like this:
import webapp2
class HomePage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hey Y'all!')
application = webapp2.WSGIApplication([
('/', HomePage),
], debug=True)
Here you can see application that we referred to in app.yaml.
Once you have this basic structure you need to start the dev appserver. The way you are doing it in the question is incorrect:
You need to run the dev_appserver with the directory "exercise1", not a python file.
Assuming that the Google App Engine sdk is still located at "~/Documents/GAE_projects/google_appengine" run the following command from the exercise1 directory:
python ~/Documents/GAE_projects/google_appengine/dev_appserver.py ./
This will start the dev_appserver.py script telling it to use the current directory (which is what the "./" means).
If you follow this, then you should be up and rolling!
Upvotes: 2