Skip to content

Latest commit

 

History

History
176 lines (123 loc) · 4.79 KB

README_SetupFrontEndCommunication.MD

File metadata and controls

176 lines (123 loc) · 4.79 KB

Real-time disaster analysis using Twitter ( Frontend )

Since the backend is based on BSON ( Binary JSON ) and the language used to communicate with the backend is python ( Apache Spark ), it would be good to have a server based on python / javascript as well. Since python functions can be called easily if the framework is based on python, prefer to use Python Flask. To make it easier, plan is to use AngularJS in future on the frontend (client side) where as use python for the server.

Objective 1:

Click of a button get the number of Tweets available in the MongoDB database.

Objective 2:

Click of a button with a parameter, figure out number of times the text appeared in the collected information.

Objective 3:

Try plotting a graph of the number of times a parameter occured against the dates it occured.

The following can be ignored if Flask was to be used directly!!

pip install Flask

  • Installing libraries for Flask
    • Bootstrap
    • Triangle ( To resolve issue between the template of AngularJS and Flask)
    • repoze.lru (Import error observed)
pip install flask-bootstrap
pip install flask-triangle
pip install repoze.lru
  • Installing npm and bower
sudo yum install nodejs npm --enablerepo=epel
mkdir /home/ec2-user/Disaster-Analysis/flaskapp/static
cd /home/ec2-user/Disaster-Analysis/flaskapp/static
bower install angularjs --save
  • Place for storing all the templates
mkdir /home/ec2-user/Disaster-Analysis/flaskapp/templates

Start MongoDB in background with a logfile

mongod --fork --logpath log_mongodb --dbpath data/
  • MongoDB Commands:
Count number of tweets that have no geolocation.
db.Tweets.find({geo: { $ne: null } }).count()

Shows all Indexes
db.Tweets.getIndexes()

Creating an Index
db.Tweets.createIndex({"text":1})

Creating Text Index for Text Query:
db.Tweets.createIndex({"text":"text"})

Text Query:
db.Tweets.find({$text: { $search: "Ivory"} })