File size: 4,495 Bytes
87df47d
 
 
 
 
062b5f0
 
 
993387b
 
062b5f0
47ea413
92080e9
 
5e917ba
8dfebbd
 
 
d43fca9
454c8a3
 
2ae84c0
68aea56
872fbee
47ea413
993387b
87df47d
 
 
 
b9f4475
7db1515
1490701
 
33f7d1a
68aea56
87df47d
a837717
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr

demo = gr.Blocks()

def fun1():
  tweet_link = "https://t.co/yZlSG6mDW6" #json_response['data'][0]['text'].split()[-1]
  tweet_text = "Exploring through Random Curiosity with General Value Functions abs: https://t.co/rnbmQcHDUu" #' '.join(json_response['data'][0]['text'].split()[:-1])
  tweet_createdat = "2022-11-21T03:33:22.000Z" #json_response['data'][0]['created_at']
  print("tweetssss ====>", tweet_text, tweet_link, tweet_createdat)
  sample_text = """<blockquote class="twitter-tweet"><p lang="en" dir="ltr">""" + tweet_text + '</p>&mdash; Yuvi (@yvrjsharma) <a href="' + tweet_link +  '">'+ tweet_createdat + """</a> </blockquote><script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>"""
  
  embed_url1 = '<a class="twitter-timeline" data-width="400" data-height="600" href="https://twitter.com/_akhaliq?ref_src=twsrc%5Etfw" target="_blank">Tweets by _akhaliq</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'
  embed_url2 = """<a class="twitter-timeline" href="https://twitter.com/_akhaliq?ref_src=twsrc%5Etfw" target="_akhaliq">Tweets by _akhaliq</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>"""
  embed_url3 = """<iframe class="twitter-timeline" href="https://twitter.com/_akhaliq?ref_src=twsrc%5Etfw">Tweets by _akhaliq</iframe> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>"""
  embed_url4 = """<a class="twitter-timeline"
  href="https://twitter.com/_akhaliq">
  Tweets by @_akhaliq
  </a>"""
  embed_url5 =  """<a class="twitter-timeline" href="https://twitter.com/marycamacho" data-widget-id="275430111547887616" target="_blank">Tweets by @marycamacho</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)) js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>"""
  embed_url6a = """<a class="twitter-timeline" href="https://twitter.com/yvrjsharma?ref_src=twsrc%5Etfw" target="_self">Tweets by yvrjsharma</a> <script async src="http://platform.twitter.com/widgets.js" charset="utf-8"> </script>"""
  embed_url6b = '<a class="twitter-timeline" href="https://twitter.com/yvrjsharma?ref_src=twsrc%5Etfw" target="_parent">Tweets by yvrjsharma</a> <script async src="http://platform.twitter.com/widgets.js" charset="utf-8"> </script>'
  embed_url6c = """<a class="twitter-timeline" href="https://twitter.com/yvrjsharma?ref_src=twsrc%5Etfw" target="_top">Tweets by yvrjsharma</a> <script async src="http://platform.twitter.com/widgets.js" charset="utf-8"\> </script\>"""
  embed_url7 = """<blockquote class="twitter-tweet"><p lang="en" dir="ltr">It&#39;s never too early to start on <a href="https://twitter.com/Gradio?ref_src=twsrc%5Etfw">@Gradio</a> and <a href="https://twitter.com/huggingface?ref_src=twsrc%5Etfw">@huggingface</a> Spaces😃- Helped my 12 yo nephew to build an ML App for his inter-school science project. This project helps in social wellbeing by giving people a choice to filter negative and positive News. <a href="https://t.co/0L1WAMQpWV">https://t.co/0L1WAMQpWV</a></p>&mdash; Yuvi (@yvrjsharma) <a href="https://twitter.com/yvrjsharma/status/1590954837533159426?ref_src=twsrc%5Etfw">November 11, 2022</a></blockquote> <script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>"""
  embed_url8 = """<blockquote class="twitter-tweet"><p lang="en" dir="ltr">It's never too early to start on @Gradio and @huggingface Spaces😃- Helped my 12 yo nephew to build an ML App for his inter-school science project. This project helps in social wellbeing by giving people a choice to filter negative and positive News. https://t.co/0L1WAMQpWV</p>&mdash; Yuvi (@yvrjsharma) <a href="https://twitter.com/yvrjsharma/status/1590954837533159426?ref_src=twsrc%5Etfw">November 11, 2022</a></blockquote><script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>"""

  return embed_url7 , sample_text, embed_url8

with demo:
  with gr.Row():
    b1 = gr.Button("Twitter Feed")
  with gr.Row():
    twitter_pane1 = gr.HTML() #gr.Markdown() #gr.HTML()
    twitter_pane2 = gr.Markdown() #gr.HTML()
    twitter_pane3 = gr.Markdown() #gr.HTML()
    #twitter_pane4 = gr.Markdown() #gr.HTML()
  b1.click(fn=fun1, outputs=[twitter_pane1, twitter_pane2 , twitter_pane3])

demo.launch(debug=True, show_error=True)