jeudi 27 octobre 2016

Python flask url variable from another route as endpoint parameter

Hello guys i am new to flask and i have 1 question. I have a route /tweeter where i show some data for the tweets which I take from twitter api with the help of tweepy. How i can pass a variable from the /twitter route to create a new route with an atribute of the variable as endpoint. for example:

@app.route('/twitter', methods=('GET', 'POST'))
  def twitter():
    tweets = api.user_timeline(screen_name = 'example', count=100, include_rts = True)

and in a new route i would like to pass tweets.text as endpoint parameter.

@app.route('/twitter/{twitter.text}')
  def newfunction(twitter.text):
.......

and some values from the tweets variable from above.




Aucun commentaire:

Enregistrer un commentaire