test_space / app.py
ysharma's picture
ysharma HF Staff
update
993387b
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)