Guest User

Untitled

a guest
Nov 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. from flask import Flask
  2. import twitter_api # name is probably different
  3.  
  4. app = Flask(__name__)
  5. oauth = OAuth()
  6.  
  7. class User(Model):
  8. id = Integer()
  9. name = String()
  10. whatever = ...
  11.  
  12. class Tweet(Model):
  13. user = String()
  14. whatever = ...
  15.  
  16. # init twitter API here, but no oauth yet
  17. t_api = twitter_api.API(whatever)
  18.  
  19. # doing normal stuff here, nothing twitter related
  20. @app.route("/")
  21. def hello():
  22. return "Hello World!"
  23.  
  24. # searching tweets, no auth required
  25. @app.route("/tweets/<searchterm>")
  26. def search(searchterm):
  27. # ask twitter API lib to search for things
  28. return results
  29.  
  30. # getting timeline here, auth needed
  31. @app.route("/timeline/<user>")
  32. def timeline(user):
  33. # ask twitter API lib to auth user and get timeline
  34. return timeline
  35.  
  36. if __name__ == "__main__":
  37. app.run()
Add Comment
Please, Sign In to add comment