Download src/streamlit_app.py from sujitv14/Test1: direct link, hf CLI and curl.
- Browser
- Download file 975 Bytes
-
https://huggingface.co/spaces/sujitv14/Test1/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/sujitv14/Test1/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/sujitv14/Test1/resolve/main/src/streamlit_app.py
975 Bytes
| import streamlit as st | |
| st.set_page_config(page_title="Add Two Numbers", page_icon="➕", layout="centered") | |
| st.title("Add Two Numbers") | |
| st.write("Enter two numbers and press `Compute` to see their sum.") | |
| # Let user choose integer or float mode | |
| mode = st.radio("Number type", ("Float", "Integer"), index=0) | |
| if mode == "Integer": | |
| a = st.number_input("First number", value=0, step=1, format="%d") | |
| b = st.number_input("Second number", value=0, step=1, format="%d") | |
| # ensure integer type | |
| a = int(a) | |
| b = int(b) | |
| else: | |
| a = st.number_input("First number", value=0.0, step=0.1, format="%.6f") | |
| b = st.number_input("Second number", value=0.0, step=0.1, format="%.6f") | |
| a = float(a) | |
| b = float(b) | |
| if st.button("Compute"): | |
| total = a + b | |
| st.success(f"Result: {total}") | |
| # show math with KaTeX/LaTeX rendering | |
| st.markdown(f"$${a} + {b} = {total}$$") | |
| else: | |
| st.info("Click Compute to perform the addition.") |