getting started google app engine using python

download and install python 2.5
http://www.python.org/ftp/python/2.5.4/python-2.5.4.msi

download and install app engine sdk for pyton
http://googleappengine.googlecode.com/files/GoogleAppEngine_1.2.3.msi

2 scripts of interest in C:/tools/google/appengine
* dev_appserver.py, the development web server
* appcfg.py, for uploading your app to App Engine

C:/tools/google/appengine>mkdir helloworld
C:/tools/google/appengine>cd helloworld
C:/tools/google/appengine/helloworld>
C:/tools/google/appengine/helloworld>vi helloworld.py

copy this and paste in helloworld.py

print 'Content-Type: text/plain'
print ''
print 'Hello, world!'

C:/tools/google/appengine/helloworld>vi app.yaml

copy this and paste in app.yaml

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py

start the webserver with following cmd

    google_appengine/dev_appserver.py helloworld/

QUESTION: how does dev_appserver.py knows where is helloworld/
on file system ?
ANSWER: dev_appserver.py calls dev_appserver_main.py

run dev_appserver.py with --debug argument

C:/tools/google/appengine>python dev_appserver.py --debug helloworld/
INFO     2009-06-21 13:05:43,641 appengine_rpc.py:157] Server: appengine.google.com
Allow dev_appserver to check for updates on startup? (Y/n): n
dev_appserver will not check for updates on startup.  To change this setting, edit C:/Documents and Settings/Administrator/.appcfg_nag
WARNING  2009-06-21 13:05:53,095 datastore_file_stub.py:404] Could not read datastore data from c:/temp/user/dev_appserver.datastore
WARNING  2009-06-21 13:05:53,095 datastore_file_stub.py:404] Could not read datastore data from c:/temp/user/dev_appserver.datastore.history
WARNING  2009-06-21 13:05:53,296 dev_appserver.py:3296] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2009-06-21 13:05:53,426 dev_appserver_main.py:465] Running application helloworld on port 8080: http://localhost:8080
=====================================================
I've added following line
    print ("=========path=%s" % path);
on line# 393 (in main method)
seems like path is relative to the dir from where we are running script

if I run from c:/

C:/>python C:/tools/google/appengine/dev_appserver.py helloworld/
=========path=helloworld/app.yaml
=========path=helloworld/app.yml
ERROR:root:Application configuration file not found in helloworld/

It cant find it.

It works with absolute path

C:/>python C:/tools/google/appengine/dev_appserver.py C:/tools/google/appengine/helloworld/
=======path=C:/tools/google/appengine/helloworld/app.yaml
INFO     2009-06-21 13:13:06,308 appengine_rpc.py:157] Server: appengine.google.com
WARNING  2009-06-21 13:13:06,328 datastore_file_stub.py:404] Could not read datastore data from c:/temp/user/dev_appserver.datastore
WARNING  2009-06-21 13:13:06,328 datastore_file_stub.py:404] Could not read datastore data from c:/temp/user/dev_appserver.datastore.history
WARNING  2009-06-21 13:13:06,348 dev_appserver.py:3296] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2009-06-21 13:13:06,378 dev_appserver_main.py:466] Running application helloworld on port 8080: http://localhost:8080

C:/tools/google/appengine>python dev_appserver.py --debug helloworld/
=========path=helloworld/app.yaml
============================
C:/tools/google/appengine>python dev_appserver.py --help
Runs a development application server for an application.

dev_appserver.py [options] 

Application root must be the path to the application to run in this server.
Must contain a valid app.yaml or app.yml file.

Options:
  --help, -h                 View this helpful message.
  --debug, -d                Use debug logging. (Default false)
  --clear_datastore, -c      Clear the Datastore on startup. (Default false)
  --address=ADDRESS, -a ADDRESS
                             Address to which this server should bind. (Default
                             localhost).
  --port=PORT, -p PORT       Port for the server to run on. (Default 8080)
  --datastore_path=PATH      Path to use for storing Datastore file stub data.
                             (Default c:/temp/user/dev_appserver.datastore)
  --history_path=PATH        Path to use for storing Datastore history.
                             (Default c:/temp/user/dev_appserver.datastore.history)
  --require_indexes          Disallows queries that require composite indexes
                             not defined in index.yaml.
  --smtp_host=HOSTNAME       SMTP host to send test mail to.  Leaving this
                             unset will disable SMTP mail sending.
                             (Default '')
  --smtp_port=PORT           SMTP port to send test mail to.
                             (Default 25)
  --smtp_user=USER           SMTP user to connect as.  Stub will only attempt
                             to login if this field is non-empty.
                             (Default '').
  --smtp_password=PASSWORD   Password for SMTP server.
                             (Default '')
  --enable_sendmail          Enable sendmail when SMTP not configured.
                             (Default false)
  --show_mail_body           Log the body of emails in mail stub.
                             (Default false)
  --auth_domain              Authorization domain that this app runs in.
                             (Default gmail.com)
  --debug_imports            Enables debug logging for module imports, showing
                             search paths used for finding modules and any
                             errors encountered during the import process.
  --allow_skipped_files      Allow access to files matched by app.yaml's
                             skipped_files (default False)
  --disable_static_caching   Never allow the browser to cache static files.
                             (Default enable if expiration set in app.yaml)


=====================================================
The web server is now running, listening for requests on port 8080.
Test the application by visiting the following URL in your web browser:

    * http://localhost:8080/

You can leave the web server running while you develop your application.
The web server knows to watch for changes in your source files and reload
them if necessary.

To shut down the web server, make sure the terminal window is active,
then press Control-C (or the appropriate "break" key for your console).

NOTE: if you get error
application configuration file not found

say you have an C:\MyDemo\HelloWorld dir which include 2 files:
helloworld.py and app.yaml

then you should go to C:\MyDemo rather than C:\MyDemo\HelloWorld to
perform the 
cmd("dev_appserver.py helloworld/"). 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s