Download utils.py from bipin/mltwitter: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/spaces/bipin/mltwitter/resolve/main/utils.py
- Command line
-
hf download hf://spaces/bipin/mltwitter/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/bipin/mltwitter/resolve/main/utils.py
896 Bytes
| import requests | |
| import streamlit as st | |
| import streamlit.components.v1 as components | |
| def get_tweet(url): | |
| api = f"https://publish.twitter.com/oembed?url={url}&maxwidth=400&theme=dark" | |
| content = requests.get(api).json() | |
| return content | |
| def display_page(urls_path): | |
| columns = st.columns([1, 1, 1]) | |
| with open(urls_path, "r") as f: | |
| urls = f.readlines() | |
| for i in range(0, len(urls)-3, 3): | |
| with columns[0]: | |
| st.write("-"*10) | |
| components.html(get_tweet(urls[i])['html'], height=283, scrolling=True) | |
| with columns[1]: | |
| st.write("-"*10) | |
| components.html(get_tweet(urls[i+1])['html'], height=283, scrolling=True) | |
| with columns[2]: | |
| st.write("-"*10) | |
| components.html(get_tweet(urls[i+2])['html'], height=283, scrolling=True) |