Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created June 27, 2012 16:54
Show Gist options
  • Save chriszf/3005376 to your computer and use it in GitHub Desktop.
Save chriszf/3005376 to your computer and use it in GitHub Desktop.
Sample flask app
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