Please note that the code verification service URL has been shifted to https://162.222.183.53. The URL has been updated in this example app.
Travis-CI is used to test and deploy updates to Google App Engine.
The Travi-CI gem will be used to encrypt a OAuth2 token that will be used to push updates to Google App Engine from the Travis build.
- From the terminal, install the gem by entering
gem install travis
###Install and run GAE Python SDK
From the console of your Nitrous.IO Box, execute the following commands:
- cd ~/
- curl https://googleappengine.googlecode.com/files/google_appengine_1.8.8.zip > gae_python-1.8.8.zip
- unzip gae_python-1.8.8.zip
- rm gae_python-1.8.8.zip
Sign up for Google App Engine if you haven’t. Create a new GAE Application. Fork this GitHub repository to your own GitHub account: https://github.com/andrewbeng89/tictactoe/. Clone the forked repository to your Nitrous.IO Box:
git clone [email protected]:<your-github-account>/tictactoe.git
- Run the development server on Nitrous.IO:
~/google_appengine/dev_appserver.py --host=0.0.0.0 --port=8080 ~/tictactoe/
- To preview the app, select “Port 8080” from the “Preview” dropdown:
To configure a new GitHub repository and GAE app:
cd tictactoe
- Reomve the .git directory
rm -rf .git
- Create a new GitHub repository with your account
- Initialise the demo app as a git repo:
git init
- Add the remote to the newly create GitHub repository
git remote add origin [email protected]:<your_username>/<your_new_repo>.git
- Create a new GAE application here
- Open the app.yaml file and edit the following line:
application: <new-gae-app-id>
The very first deployment to GAE has to be made from the Nitrous.IO in order to retrieve the OAuth2 refresh_token which Travis-CI will use later
- From the console, enter
appcfg.py --noauth_local_webserver --oauth2 update ./
- A link will be displayed, followed by a promt to enter an access code. Open the link in a new browser tab and allow Google to grant access. Copy the access code displayed to the clipboard
- Paste the access code in the VM terminal and hit return
- Open the .appcfg_oauth2_tokens (JSON) file and copy the value of the refresh_token field
- Remove this line from the .travis.yml file
secure: <existing secure token>
- Encrypt this token as a secure global variable in the .travis.yml file
travis encrypt MY_GAE_TOKEN="<paste_token_from_clipboard>" --add -r <your_github_username/your_github_repo>
- Check the .travis.yml file to see whether the new secure variable has been added
- Register for Travis-CI using your GitHub account
- From your Travis-CI profile page, enable the newly created GitHub repository
- Edit this line of the .travis.yml file:
- git clone https://github.com/<your_username>/<your_repo>.git deploy
- Add all file and folders
git add -A .
- Commit with message
git commit -a -m 'created GAE project'
- Push the update
git push origin master
- You can track the build progress at the Travis-CI website
The Nose module allows developers to create simple functional and unit tests. In this sample app, the tests are in the /test.py file. This file tests the funcitonality of a single API call /api/get_bots. To break this test:
- Edit line 96 in main.py to
@bottle.route('/api/get_bot')
- Commit and push the changes
- Track the build progress on travis-ci
View the GameBots demo app here
A skeleton for building Python applications on Google App Engine with the Bottle micro framework version 0.11.6
See our other Google Cloud Platform github repos for other sample applications.
-
Install the App Engine Python SDK. See the README file for directions. You'll need python 2.7 and pip 1.4 or later installed too.
-
Clone this repository with
git clone https://github.com/GoogleCloudPlatform/appengine-python-bottle-skeleton.git
-
Install dependencies in the project's lib/ directory - App Engine can only import libraries from inside your project directory.
cd appengine-python-bottle-skeleton pip install -r requirements.txt -t lib/
-
Run this project locally from the command line:
dev_appserver.py <projectDirectory>
See the development server documentation for options when running dev_appserver.
To deploy the application:
- Use the Admin Console to create an app and get the project/app id. (App id and project id are identical)
- Deploy the application with
appcfg.py -A <your-project-id> --oauth2 update <projectDirectory>
- Congratulations! Your application is now live at your-project-id.appspot.com
This skeleton includes TODO markers you can search for to determine some of the basic areas you will want to customize.
To add persistence to your models, use NDB for scale. Consider CloudSQL if you need a relational database.
See the Third party libraries page for libraries that are already included in the SDK. To include SDK libraries, add them in your app.yaml file. All other libraries must be included in your project directory in order to be used by App Engine. Only pure python libraries may be added to an App Engine project.
Star this repo if you found it useful. Use the github issue tracker to give feedback on this repo and to ask for skeletons for other frameworks or use cases.
See CONTRIB.md
Note, this project includes source files that are licensed under terms other than Apache 2.0.
Logan Henriquez and Johan Euphrosine