Render Custom HTML from the Directory

I am trying to use a hyperlink in my streamlit webapp. On clicking the same, it should load the html file (from the local directory) in a new tab. I have attached a code snippet depicting the same.

I am not well conversant with HTML, I am trying to figure out a simple way. :thinking:

Kindly suggest…

Streamlit Code

import streamlit as st
legend=    """<html> 
    <body> 
        <h2>Terms & Condition</h2> 
        <p><a href=TnC.html>My Custom Webpage</a></p> 
        </h1> 
    </body>
    </html>"""
    
st.markdown(legend, unsafe_allow_html=True)

TnC HTML Code

<html>
<head></head>
<body>
<p>Terms & Conditions</p>
  
</body>
</html>

Output
streamlit

TnC.html needs to be served from a webserver to be rendered in a bowser. Double clicking an html file on your filesystem and seeing it open is just convenient voodoo of the operating system shell that isn’t a web native concept. :see_no_evil:

You can fake opening static HTML files using a blank/empty component, by taking advantage of its frontend folder. See the trick I used here: This is how to use Sweetviz with Streamlit

HTH,
Arvindra