Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
89 lines (71 loc) · 2.32 KB
/
Copy pathapp.py
File metadata and controls
89 lines (71 loc) · 2.32 KB
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
import streamlit as st
from bs4 import BeautifulSoup
from scraper import get_oneplus9_specs
import textwrap
st.set_page_config(
page_title="MIACTool",
layout="wide",
initial_sidebar_state="expanded"
)
# ---------- SESSION STATE ----------
if "screen" not in st.session_state:
st.session_state.screen = "home"
if "query" not in st.session_state:
st.session_state.query = ""
# ---------- RESULT FUNCTION ----------
def show_result_card():
specs = get_oneplus9_specs()
mrp = specs.get("MRP", "Not Found")
performance = specs.get("Performance", "Not Found")
# wrap the string in dedent to strip the leading whitespace
html_template = textwrap.dedent(f"""
<div class="result-wrapper">
<div class="result-card">
<h2 class="phone-title">OnePlus 9</h2>
<div class="spec-row">
<div class="spec-label">MRP</div>
<div class="spec-value">{mrp}</div>
</div>
<div class="spec-row">
<div class="spec-label">Performance</div>
<div class="spec-value">{performance}</div>
</div>
<h3 class="public-heading">Public Opinion</h3>
<p class="public-text">
Live scraped data loaded successfully.
</p>
</div>
</div>
""")
st.markdown(html_template, unsafe_allow_html=True)
# Load CSS
def load_css():
with open("styles.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
load_css()
# Sidebar
with st.sidebar:
st.markdown("## History")
st.markdown("**Current Chat**")
st.markdown("Previous Topic")
# ---------- UI LOGIC ----------
if st.session_state.screen == "home":
st.markdown("""
<div class="center-container">
<h1 class="welcome-text">Welcome, Seeker.</h1>
</div>
""", unsafe_allow_html=True)
query = st.text_input(
"Search",
placeholder="Please enter a topic",
label_visibility="collapsed"
)
if query:
st.session_state.query = query
st.session_state.screen = "result"
st.rerun()
elif st.session_state.screen == "result":
show_result_card()
if st.button("⬅ Back"):
st.session_state.screen = "home"
st.rerun()