Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask
- import twitter_api # name is probably different
- app = Flask(__name__)
- oauth = OAuth()
- class User(Model):
- id = Integer()
- name = String()
- whatever = ...
- class Tweet(Model):
- user = String()
- whatever = ...
- # init twitter API here, but no oauth yet
- t_api = twitter_api.API(whatever)
- # doing normal stuff here, nothing twitter related
- @app.route("/")
- def hello():
- return "Hello World!"
- # searching tweets, no auth required
- @app.route("/tweets/<searchterm>")
- def search(searchterm):
- # ask twitter API lib to search for things
- return results
- # getting timeline here, auth needed
- @app.route("/timeline/<user>")
- def timeline(user):
- # ask twitter API lib to auth user and get timeline
- return timeline
- if __name__ == "__main__":
- app.run()
Add Comment
Please, Sign In to add comment