Skip to content

Commit 88f1a28

Browse files
committed
feat: add initial streamlit app
1 parent 0720353 commit 88f1a28

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

app/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Use an official Python runtime as the base image
2+
FROM python:3.10-slim
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the current directory contents into the container at /app
8+
COPY app /app
9+
10+
# Install the required packages
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
14+
# Expose the port Streamlit runs on
15+
EXPOSE 8501
16+
17+
# Run the Streamlit app
18+
CMD ["streamlit", "run", "streamlit_app.py"]

app/requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
streamlit
3+
requests
4+
python-dotenv

app/streamlit_app.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import streamlit as st
2+
import requests
3+
4+
# OAuth login (to be implemented)
5+
# ...
6+
7+
8+
def main():
9+
# Use st.write with HTML for the title
10+
st.write("<h1>FastAPI Streamlit Demo</h1>", unsafe_allow_html=True)
11+
12+
# Demo GET request
13+
if st.button("Get Data"):
14+
response = requests.get("http://localhost:8000/")
15+
st.write(response.json())
16+
17+
# Demo POST request
18+
data = st.text_input("Enter data to post:")
19+
if st.button("Post Data"):
20+
# Endpoint to be implemented in the API
21+
response = requests.post("http://localhost:8000/demo_post", json={"data": data})
22+
st.write(response.json())
23+
24+
25+
if __name__ == "__main__":
26+
main()

0 commit comments

Comments
 (0)