Upload files to "frontend"

This commit is contained in:
maq
2025-10-30 04:05:52 -07:00
parent 5f4cafe837
commit 5c0103834e
3 changed files with 47 additions and 0 deletions

7
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]

37
frontend/app.py Normal file
View File

@@ -0,0 +1,37 @@
import streamlit as st
import requests
import pandas as pd
import io
import os
st.title("🚀 Deal Hunter App")
st.sidebar.header("Search & Filters")
item = st.sidebar.text_input("Item", value="iPhone 14 Pro Max")
radius = st.sidebar.number_input("Radius (miles)", value=50)
min_price = st.sidebar.number_input("Min Price", value=0.0)
max_price = st.sidebar.number_input("Max Price", value=1000.0)
condition = st.sidebar.selectbox("Condition", ["Any", "New", "Used"])
min_score = st.sidebar.slider("Min Score", 1, 10, 7)
backend_url = os.getenv("BACKEND_URL", "http://localhost:8000")
if st.button("Hunt Deals"):
with st.spinner("Hunting..."):
response = requests.post(f"{backend_url}/hunt", json={
"item": item, "location_radius": radius, "min_price": min_price, "max_price": max_price,
"condition": condition, "min_score": min_score
})
if response.status_code == 200:
data = response.json()
deals = data['deals']
hot_count = data['hot_count']
df = pd.DataFrame(deals)
st.success(f"Found {len(deals)} deals ({hot_count} hot)!")
st.dataframe(df[['title', 'price', 'resale_avg', 'offer', 'score', 'status', 'condition', 'link']], use_container_width=True)
csv_buffer = io.StringIO(data['csv'])
st.download_button("Download CSV", csv_buffer.getvalue(), "deals.csv", "text/csv")
else:
st.error(f"Error: {response.text}")
st.info("Backend API at http://localhost:8000 for testing.")

View File

@@ -0,0 +1,3 @@
streamlit
requests
pandas