DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Building a Python Web Application Using Flask and Neo4j

Building a Python Web Application Using Flask and Neo4j

Andreas Kollegger user avatar by
Andreas Kollegger
·
Feb. 02, 15 · Java Zone · Interview
Like (0)
Save
Tweet
6.55K Views

Join the DZone community and get the full member experience.

Join For Free

flask, a popular python web framework, has many tutorials available online which use an sql database to store information about the website’s users and their activities.  while sql is a great tool for storing information such as usernames and passwords, it is not so great at allowing you to find connections among your users for the purposes of enhancing your website’s social experience.

the quickstart flask tutorial builds a microblog application using sqlite. in my tutorial , i walk through an expanded, neo4j-powered version of this microblog application that uses py2neo , one of neo4j’s python drivers, to build social aspects into the application. this includes recommending similar users to the logged-in user, along with displaying similarities between two users when one user visits another user’s profile.

my microblog application consists of users, posts, and tags modeled in neo4j:

http://i.imgur.com/9nuvbpz.png

with this graph model, it is easy to ask questions such as:

“what are the top tags of posts that i’ve liked?”

match (me:user)-[:liked]->(post:post)<-[:tagged]-(tag:tag)
where me.username = 'nicole'
return tag.name, count(*) as count
order by count desc
“which user is most similar to me based on tags we’ve both posted about?”
match (me:user)-[:published]->(:post)<-[:tagged]-(tag:tag), (other:user)-[:published]->(:post)<-[:tagged]-(tag)
where me.username = 'nicole' and me <> other
with other,

    collect(distinct tag.name) as tags,
    count(distinct tag) as len

order by len desc limit 3
return other.username as similar_user, tags 
links to the full walkthrough of the application and the complete code are below.
      tutorial
      github
if you would like a live walkthrough, be sure to register for my upcoming webinar on building a python web application with flask and neo4j.

Web application Python (language) Neo4j Flask (web framework)

Published at DZone with permission of Andreas Kollegger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Password Authentication: How to Correctly Do It
  • What Is URL Rewriting? | Java Servlets
  • Don't Underestimate Documentation
  • Java Hashtable, HashMap, ConcurrentHashMap: Performance Impact

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo