Build a Twitter Analytics App
2 The First Step: Design Your Solution
6 Writing the Backend Twitter Server
Writing the Code in Small Parts: Part 1, The Basic App
Part 2: Adding a Counter to Exit
Part 3: Adding Language and Retweet Count
7 Adding the Data to a Database
8 Testing: What and How to Test
9 Displaying our Data using the Flask Webserver
9.2 Adding templates to our Flask app
9.3 Displaying our Tweets in the Flask Web Server
10 Future Work and Improvements
This is a very quick introduction to the Flask web server. Make sure you have the hello world equivalent of Flask working, and then briefly look at the quickstart.
We’ll start very simple, just one step above the hello world level program. Get the code from here.
1 2 3 4 5 6 7 |
from flask import Flask, render_template app = Flask(__name__) @app.route("/") def main(): return "Most used languages on Twitter: All Tweets" |
All the code above does is print Most used languages on Twitter: All Tweets when you go to http://127.0.0.0:5000.
Similarly:
1 2 3 4 5 6 7 |
@app.route("/top_tweets") def top_tweets(): return "Most Popular Tweets" @app.route("/trends") def trends(): return "Trending On Twitter:" |
This time, we are adding two new routes. http://127.0.0.0:5000/top_tweets will take us to the top tweets page. http://127.0.0.0:5000/trends will take us (surprise) to the trends page.