Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This is the code to go along with the OpenShift blog piece on how to use Flask (python) with MongoDB to create a REST like web service with spatial data

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fixing urls

latest commit 4cc92547a2
Dan McPherson danmcp authored April 07, 2014
Octocat-spinner-32 .openshift V2 cart compatibility June 04, 2013
Octocat-spinner-32 data prepping to move up to github August 13, 2012
Octocat-spinner-32 libs prepping to move up to github August 13, 2012
Octocat-spinner-32 wsgi Bug 966465 June 01, 2013
Octocat-spinner-32 .gitignore Update .gitignore August 13, 2012
Octocat-spinner-32 README Use OpenShift consistently March 31, 2014
Octocat-spinner-32 README.md Fixing urls April 07, 2014
Octocat-spinner-32 parkcoord.json prepping to move up to github August 13, 2012
Octocat-spinner-32 setup.py Update setup.py August 15, 2013
README.md

openshift-mongo-flask-example

This is the code to go along with the OpenShift blog piece on how to use Flask (python) with MongoDB to create a REST like web service with spatial data Please note that this only works with Python-2.6 cartridge

Running on OpenShift

Create an account at https://www.openshift.com

Create a python application with MongoDB

rhc app create pythonws python-2.6 mongodb-2 --from-code git://github.com/openshift-quickstart/openshift-mongo-flask-example.git

or you can do this

rhc app create pythonws python-2.6 mongodb-2
cd pythonws
git remote add upstream -m master git://github.com/openshift-quickstart/openshift-mongo-flask-example.git
git pull -s recursive -X theirs upstream master
git push

To add the data to the MongoDB instance please follow the instructions on this blog: Mongo Spatial on OpenShift

Now, ssh into the application.

Add the data to a collection called parkpoints:

mongoimport -d pythonws -c parkpoints --type json --file $OPENSHIFT_REPO_DIR/parkcoord.json  -h $OPENSHIFT_MONGODB_DB_HOST  -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD --port $OPENSHIFT_MONGODB_DB_PORT

Create the spatial index on the documents:

mongo
use pythonws
db.parkpoints.ensureIndex( { pos : "2d" } );

Once the data is imported you can now checkout your application at:

http://pythonws-$yournamespace.rhcloud.com/ws/parks

License

This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to CC0 (http://creativecommons.org/publicdomain/zero/1.0/)

Something went wrong with that request. Please try again.