How to render already prepared html code with Streamlit?

I would like to render an already prepared HTML block inside the page served by Streamlit.
Any proposal on how to do that?

Hi @striki, welcome to the Streamlit Community!

When you say “already prepared”, do mean that you have a block of HTML you want to serve? Or are you looking to embed another website?

I’m using ktrain Python package for extracting answers to a given question from the provided text.
What I’m getting as a return value is an html-formatted string with

and tags, as shown in https://towardsdatascience.com/build-an-open-domain-question-answering-system-with-bert-in-3-lines-of-code-da0131bc516b

What I also need is to present a clickable link to the page where the answer on the question was found.
Is this possible, and how?

Thanks in advance,
Stojancho

Unfortunately, that link is paywalled for me, but if you have an HTML string, you can do the following:

import streamlit as st

html_string = "<h3>this is an html string</h3>"

st.markdown(html_string, unsafe_allow_html=True)
1 Like

Example of a need to render html content is to present pandas dataframes and their content given by pandas library. On this way can see what we are seeing in Jupyter notebooks. I understand that usecases for Streamlit and Jupyter are different, but this possibility seems to be nice to have.

I might be misunderstanding, but Streamlit already displays the output of dataframes through st.write() or using Streamlit magics

https://docs.streamlit.io/en/latest/api.html#magic-commands