Spaces:
Running
Running
File size: 4,506 Bytes
ea482bf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | import streamlit as st
import requests
from bs4 import BeautifulSoup
# Page Configuration
st.set_page_config(
page_title="What is Streamlit?",
page_icon="π",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS for better styling
st.markdown("""
<style>
.stApp {
max-width: 1200px;
margin: 0 auto;
}
.definition-box {
background-color: #f0f2f6;
border-left: 5px solid #3898ec;
padding: 20px;
border-radius: 5px;
margin: 20px 0;
}
.code-block {
background-color: #282c34;
color: #abb2bf;
padding: 15px;
border-radius: 5px;
font-family: 'Courier New', monospace;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
cursor: help;
}
</style>
""", unsafe_allow_html=True)
# Header Section
st.title("π What is Streamlit?")
st.markdown("An interactive, web-based framework for building data science applications and machine learning prototypes.")
# Footer
st.markdown("---")
st.markdown("Built with anycoder | [Link](https://huggingface.co/spaces/akhaliq/anycoder)")
# Main Content
col1, col2 = st.columns([2, 1])
with col1:
st.header("π Definition")
definition_box = st.container()
with definition_box:
st.markdown("""
<div class='definition-box'>
<p><strong>Streamlit</strong> is an open-source Python library that lets you create beautiful, custom web apps for machine learning and data science projects in minutes.</p>
<br>
<p>Instead of writing HTML, CSS, and JavaScript, you write simple Python scripts. Streamlit automatically handles the frontend, allowing you to focus on the logic and algorithms.</p>
</div>
""", unsafe_allow_html=True)
st.subheader("Key Features")
features = [
"β
<strong>Rapid Development:</strong> Build apps in minutes, not weeks.",
"β
<strong>No Frontend Knowledge Required:</strong> Pure Python.",
"β
<strong>Real-time Interactivity:</strong> Widgets, sliders, and plots update instantly.",
"β
<strong>Open Source:</strong> Free to use and contribute to.",
"β
<strong>Community Support:</strong> Large community of users and developers."
]
for feature in features:
st.markdown(feature, unsafe_allow_html=True)
with col2:
st.header("π» How it Works")
st.info("""
1. **Script Execution**: Streamlit reads your Python script from top to bottom.
2. **Widget Creation**: It automatically converts inputs into interactive UI elements.
3. **State Management**: It tracks the state of the app and re-runs the script when data changes.
4. **UI Rendering**: It generates HTML, CSS, and JavaScript for the browser.
""")
st.header("π― Use Cases")
use_cases = [
"Data Exploration",
"Machine Learning Prototypes",
"Dashboards & Reports",
"Explainable AI (XAI)",
"Automated Workflows"
]
for uc in use_cases:
st.markdown(f"- {uc}")
st.markdown("---")
# Interactive Demo Section
st.header("π― Try It Yourself: The Hello World of Streamlit")
st.markdown("""
Below is a simple code snippet that creates an interactive counter.
In Streamlit, you don't need to write complex HTML formsβjust use the `st.write()` and `st.button()` functions.
""")
code_example = """
import streamlit as st
st.title("Hello Streamlit!")
# Create a button
if st.button("Click Me"):
st.write("Button clicked! π")
st.write(f"Count: {st.session_state.get('count', 0) + 1}")
"""
st.markdown("### Example Code")
st.code(code_example, language="python")
st.markdown("### Live Demo")
st.info("Copy the code above into a Python file and run it with `streamlit run filename.py` to see it in action!")
# Additional Resources
st.markdown("---")
st.header("π Additional Resources")
st.markdown("""
### Official Documentation
- [Streamlit Docs](https://docs.streamlit.io/) - Comprehensive guides and API reference.
- [Streamlit Gallery](https://streamlit.io/gallery) - See what others have built.
### Getting Started
- **Installation**: `pip install streamlit`
- **Running an App**: `streamlit run your_app.py`
- **Command Line**: `streamlit run your_app.py --server.port 8080`
""")
# Footer
st.markdown("---")
st.markdown("Built with anycoder | [Link](https://huggingface.co/spaces/akhaliq/anycoder)") |