Created
June 27, 2012 16:54
-
-
Save chriszf/3005376 to your computer and use it in GitHub Desktop.
Sample flask app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, session, g, redirect, url_for, \ | |
abort, render_template, flash | |
import tweepy | |
SECRET_KEY = 'development key' | |
DEBUG = True | |
app = Flask(__name__) | |
app.config.from_object(__name__) | |
##### Fill in stuff here | |
@app.route("/public") | |
def public_timeline(): | |
timeline = tweepy.api.public_timeline() | |
return render_template("public.html", | |
tweets = timeline) | |
@app.route("/user/<name>") | |
def get_user(name): | |
user = tweepy.api.get_user(name) | |
friends = user.friends() | |
num_friends = len(friends) | |
output = render_template("user.html", | |
u = user, | |
friends = friends, | |
num_friends = num_friends) | |
print output | |
return output | |
##### End stuff | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment