2. WHO AM I
•
Shekhar Gulati – Works at Red Hat
•
Principal OpenShift Developer Evangelist
•
Java / Python/ JavaScript / NoSQL / Cloud Guy
•
Twitter Handle : shekhargulati
•
Github https://github.com/shekhargulati
•
Slides http://www.slideshare.net/shekhargulati
3. AGENDA
➔ Learn a bit about Flask
➔ Learn some MongoDB basics
➔ Build a location aware Job search application
➔ Go live with a Flask MongoDB powered app in ~ 50
mins
4. Write an application and host it on internet
http://localjobsdemo-shekhargulati.rhcloud.com/
GOAL
9. ● Flask is a microframework for web application
development in Python
● Microframework refers to simplicity and small size of
framework
● It is inspired by Sinatra(Ruby framework to create
web apps with minimum fuss)
● Built on Werkzeug , Jinja2 , WSGI
● Good sensible defaults
FLASK
10. ● Easy to learn – dead simple
● Simple but extensible
● Excellent documentation spread over 280 pages with
lots of examples
● Very active community
● It has minimal footprint
● Does not make choice for you
● Unit testing support
WHY FLASK?
15. 15
Open Source NoSQL document datastore
– JSON style documents
Schema-less
– Each document is heterogeneous, and may have completely unique
structure compared to other documents
Fast and horizontally scalable
Rich query language
Rich documents
Easy to get running
Geospatial indexing
WHAT IS MONGODB
17. 17
What is it for?
Find all the MongoDB jobs near me – Proximity Queries
Find all the MongoDB jobs within Tokyo – Bounded Queries
Find all the MongoDB job at this location – Exact Queries
●
Supports only two dimensional indexes.
You can only have one geospatial index per collection.
By default, 2d geospatial indexes assume longitude and
latitude have boundaries of -180 inclusive and 180 non-
inclusive (i.e. [-180, 180))
GEOSPATIAL INDEXING
BASICS
18. 18
1) Put your coordinates into an array
{ loc : [ 50 , 30 ] } //SUGGESTED OPTION
{ loc : { x : 50 , y : 30 } }
{ loc : { foo : 50 , y : 30 } }
1) { loc : { lon : 40.739037, lat: 73.992964 } }
2) Make a 2d index
db.jobs.ensureIndex( { loc : "2d" } )
3) If you use latitude and longitude as your coordinate system,
always store longitude first. MongoDB’s 2d spherical index
operators only recognize [ longitude, latitude] ordering.
HOW TO MAKE IT WORK
19. 19
// Find all the jobs with skill as mongodb
db.jobs.find({"skills":"mongodb"})
// Find all the jobs with python as skill and
near to given location
db.jobs.find({"lngLat":{$near :
[139.69 , 35.68]},
"skills":"python"})
// Find all the python or mongodb jobs
near to given location
db.jobs.find({"lngLat":{$near :
[139.69 , 35.68]},
"skills":{$in :
["mongodb","python"]}})
SOME QUERIES
20.
21. Platform as a Service delivers
• Application run-time environment in the cloud
• Configures & manages both the cloud & stack for your
application
“The cloud is now useful!”