Components.v1 html error

Hi, I am using components.v1 html to embed twitter feeds of an account. It prints out the followoing error/message after the hmtl:

my code:
def embedTweet(tw_url):
api = ‘https://publish.twitter.com/oembed?url={}’.format(tw_url)
response = requests.get(api)
res = response.json()[“html”]
return components.html(res, height= 500, scrolling =True )
with col4:
st.markdown(embedTweet(‘https://twitter.com/Automotive_News’))

error:
DeltaGenerator(_root_container=0, _provided_cursor=LockedCursor(_root_container=0, _index=1, _parent_path=(2, 4), _props={‘delta_type’: ‘iframe’, ‘last_index’: None}), _parent=DeltaGenerator(_root_container=0, _provided_cursor=RunningCursor(_root_container=0, _parent_path=(2, 4), _index=2), _parent=DeltaGenerator(_root_container=0, _provided_cursor=RunningCursor(_root_container=0, _parent_path=(2,), _index=5), _parent=DeltaGenerator(_root_container=0, _provided_cursor=None, _parent=None, _block_type=None, _form_data=None), _block_type=‘horizontal’, _form_data=FormData(form_id=‘’)), _block_type=‘column’, _form_data=FormData(form_id=‘’)), _block_type=None, _form_data=None)

Please help :slight_smile:

Hi @Umut, welcome to the Streamlit community! :wave:

You’re seeing the DeltaGenerator block because you’re wrapping components.html with st.markdown. The fix is to display embedTweet in col4, without st.markdown, like so:

import streamlit as st
import requests
import streamlit.components.v1 as components

def embedTweet(tw_url):
    api = "https://publish.twitter.com/oembed?url={}".format(tw_url)
    response = requests.get(api)
    res = response.json()["html"]
    return components.html(res, height=500, scrolling=True)

embedTweet("https://twitter.com/Automotive_News")

Happy Streamlit-ing! :balloon:
Snehan

Hi @snehankekre, thank you for the solution!!