Upload files to "frontend"
This commit is contained in:
7
frontend/Dockerfile
Normal file
7
frontend/Dockerfile
Normal 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
37
frontend/app.py
Normal 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.")
|
||||
3
frontend/requirements.txt
Normal file
3
frontend/requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
streamlit
|
||||
requests
|
||||
pandas
|
||||
Reference in New Issue
Block a user