Spaces:
Sleeping
Sleeping
Maryam Ilka commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,16 +8,8 @@ import os
|
|
| 8 |
import json
|
| 9 |
import random
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
# تنظیمات اولیه
|
| 14 |
-
|
| 15 |
-
st.set_page_config(
|
| 16 |
-
layout="wide", # حالت گسترده برای همه دستگاهها
|
| 17 |
-
page_title="راهیار - تحلیل انصاف قیمتی",
|
| 18 |
-
page_icon="🚖",
|
| 19 |
-
initial_sidebar_state="auto" # تنظیم خودکار وضعیت نوار کناری
|
| 20 |
-
)
|
| 21 |
|
| 22 |
# ========== تنظیمات دیتا ==========
|
| 23 |
SHEET_ID = "1mmdWAyOCYq4yXMgP53Duq712AnlqZWLkfIo76JqM7wM"
|
|
@@ -30,34 +22,49 @@ st.markdown("""
|
|
| 30 |
font-family: 'Vazir';
|
| 31 |
src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/Vazir.woff') format('woff');
|
| 32 |
}
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
/* ریست پیشفرض مرورگرها */
|
| 36 |
* {
|
| 37 |
-
margin: 0;
|
| 38 |
-
padding: 0;
|
| 39 |
-
box-sizing: border-box;
|
| 40 |
font-family: 'Vazir', sans-serif !important;
|
| 41 |
text-align: right !important;
|
| 42 |
direction: rtl !important;
|
| 43 |
}
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
-
|
| 49 |
-
|
| 50 |
-
-
|
|
|
|
| 51 |
}
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
}
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
.likert-btn {
|
| 62 |
margin: 5px;
|
| 63 |
padding: 10px 15px;
|
|
@@ -99,53 +106,38 @@ st.markdown("""
|
|
| 99 |
padding-right: 15px;
|
| 100 |
border-right: 3px solid #6a0dad;
|
| 101 |
}
|
| 102 |
-
/* کلاسهای اصلی با رنگهای ثابت */
|
| 103 |
-
.rahyar-header {
|
| 104 |
-
background-color: var(--primary-color) !important;
|
| 105 |
-
color: white !important;
|
| 106 |
-
}
|
| 107 |
-
.price-container {
|
| 108 |
-
background-color: #f8f9fa !important;
|
| 109 |
-
border-right: 5px solid var(--primary-color) !important;
|
| 110 |
-
}
|
| 111 |
-
.rahyar-price {
|
| 112 |
-
color: var(--primary-color) !important;
|
| 113 |
-
}
|
| 114 |
-
.rahyar-btn {
|
| 115 |
-
background-color: var(--primary-color) !important;
|
| 116 |
-
color: white !important;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
|
| 120 |
</style>
|
| 121 |
""", unsafe_allow_html=True)
|
| 122 |
|
| 123 |
# ========== توابع اصلی ==========
|
| 124 |
-
|
| 125 |
def create_ride_map():
|
|
|
|
|
|
|
| 126 |
start_point = [35.7698, 51.4116] # میدان ونک
|
| 127 |
end_point = [35.8044, 51.4258] # میدان تجریش
|
| 128 |
|
| 129 |
m = folium.Map(location=[35.7871, 51.4187], zoom_start=13)
|
| 130 |
|
| 131 |
# اضافه کردن مبدأ و مقصد
|
| 132 |
-
folium.Marker(
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
# خط مسیر
|
| 136 |
-
folium.PolyLine(
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
<style>
|
| 143 |
-
.folium-map {
|
| 144 |
-
width: 100% !important;
|
| 145 |
-
height: 100% !important;
|
| 146 |
-
}
|
| 147 |
-
</style>
|
| 148 |
-
"""))
|
| 149 |
|
| 150 |
return m
|
| 151 |
|
|
@@ -298,7 +290,7 @@ def map_view():
|
|
| 298 |
"""نمایش نقشه و قیمت"""
|
| 299 |
st.markdown("""
|
| 300 |
<div style="display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px;">
|
| 301 |
-
<img src="
|
| 302 |
<div>
|
| 303 |
<h2 style="color: #6a0dad; margin: 0;">راهیار 🚖</h2>
|
| 304 |
<p style="color: #6a0dad; margin: 0;">سفرهای درون شهری سریع و مطمئن</p>
|
|
@@ -310,13 +302,14 @@ def map_view():
|
|
| 310 |
folium_static(create_ride_map(), width=800, height=400)
|
| 311 |
|
| 312 |
st.markdown(f"""
|
| 313 |
-
<div class="price-container"
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
|
|
|
| 317 |
</div>
|
| 318 |
-
|
| 319 |
-
|
| 320 |
show_explanation(st.session_state.scenario_type)
|
| 321 |
|
| 322 |
if st.button("درخواست راهیار", key="request_btn", type="primary"):
|
|
|
|
| 8 |
import json
|
| 9 |
import random
|
| 10 |
|
|
|
|
|
|
|
| 11 |
# تنظیمات اولیه
|
| 12 |
+
st.set_page_config(layout="wide", page_title="راهیار - تحلیل انصاف قیمتی", page_icon="🚖")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# ========== تنظیمات دیتا ==========
|
| 15 |
SHEET_ID = "1mmdWAyOCYq4yXMgP53Duq712AnlqZWLkfIo76JqM7wM"
|
|
|
|
| 22 |
font-family: 'Vazir';
|
| 23 |
src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/Vazir.woff') format('woff');
|
| 24 |
}
|
| 25 |
+
|
|
|
|
|
|
|
| 26 |
* {
|
|
|
|
|
|
|
|
|
|
| 27 |
font-family: 'Vazir', sans-serif !important;
|
| 28 |
text-align: right !important;
|
| 29 |
direction: rtl !important;
|
| 30 |
}
|
| 31 |
+
|
| 32 |
+
.rahyar-header {
|
| 33 |
+
background-color: #6a0dad;
|
| 34 |
+
padding: 15px;
|
| 35 |
+
border-radius: 10px;
|
| 36 |
+
color: white;
|
| 37 |
+
margin-bottom: 20px;
|
| 38 |
+
text-align: center;
|
| 39 |
}
|
| 40 |
+
|
| 41 |
+
.price-container {
|
| 42 |
+
background-color: #f8f9fa;
|
| 43 |
+
border-radius: 10px;
|
| 44 |
+
padding: 15px;
|
| 45 |
+
margin: 15px 0;
|
| 46 |
+
border-right: 5px solid #6a0dad;
|
| 47 |
}
|
| 48 |
+
|
| 49 |
+
.rahyar-price {
|
| 50 |
+
color: #6a0dad;
|
| 51 |
+
font-size: 28px;
|
| 52 |
+
font-weight: bold;
|
| 53 |
+
text-align: center;
|
| 54 |
+
margin: 10px 0;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.rahyar-btn {
|
| 58 |
+
background-color: #6a0dad !important;
|
| 59 |
+
color: white !important;
|
| 60 |
+
border: none !important;
|
| 61 |
+
padding: 10px 20px !important;
|
| 62 |
+
border-radius: 8px !important;
|
| 63 |
+
font-weight: bold !important;
|
| 64 |
+
margin: 5px 0 !important;
|
| 65 |
+
width: 100% !important;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
.likert-btn {
|
| 69 |
margin: 5px;
|
| 70 |
padding: 10px 15px;
|
|
|
|
| 106 |
padding-right: 15px;
|
| 107 |
border-right: 3px solid #6a0dad;
|
| 108 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</style>
|
| 110 |
""", unsafe_allow_html=True)
|
| 111 |
|
| 112 |
# ========== توابع اصلی ==========
|
|
|
|
| 113 |
def create_ride_map():
|
| 114 |
+
"""ایجاد نقشه سفر با Folium"""
|
| 115 |
+
# مختصات تهران (میدان ونک تا میدان تجریش)
|
| 116 |
start_point = [35.7698, 51.4116] # میدان ونک
|
| 117 |
end_point = [35.8044, 51.4258] # میدان تجریش
|
| 118 |
|
| 119 |
m = folium.Map(location=[35.7871, 51.4187], zoom_start=13)
|
| 120 |
|
| 121 |
# اضافه کردن مبدأ و مقصد
|
| 122 |
+
folium.Marker(
|
| 123 |
+
start_point,
|
| 124 |
+
popup="<b>مبدأ:</b> میدان ونک",
|
| 125 |
+
icon=folium.Icon(color="green", icon="flag", prefix="fa")
|
| 126 |
+
).add_to(m)
|
| 127 |
+
|
| 128 |
+
folium.Marker(
|
| 129 |
+
end_point,
|
| 130 |
+
popup="<b>مقصد:</b> میدان تجریش",
|
| 131 |
+
icon=folium.Icon(color="red", icon="flag", prefix="fa")
|
| 132 |
+
).add_to(m)
|
| 133 |
|
| 134 |
# خط مسیر
|
| 135 |
+
folium.PolyLine(
|
| 136 |
+
[start_point, end_point],
|
| 137 |
+
color="#6a0dad",
|
| 138 |
+
weight=3,
|
| 139 |
+
opacity=1
|
| 140 |
+
).add_to(m)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
return m
|
| 143 |
|
|
|
|
| 290 |
"""نمایش نقشه و قیمت"""
|
| 291 |
st.markdown("""
|
| 292 |
<div style="display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px;">
|
| 293 |
+
<img src="https://via.placeholder.com/100/6a0dad/FFFFFF?text=راهیار" width="80">
|
| 294 |
<div>
|
| 295 |
<h2 style="color: #6a0dad; margin: 0;">راهیار 🚖</h2>
|
| 296 |
<p style="color: #6a0dad; margin: 0;">سفرهای درون شهری سریع و مطمئن</p>
|
|
|
|
| 302 |
folium_static(create_ride_map(), width=800, height=400)
|
| 303 |
|
| 304 |
st.markdown(f"""
|
| 305 |
+
<div class="price-container">
|
| 306 |
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
| 307 |
+
<span>راهیار <span class="rahyar-badge">به صرفه</span></span>
|
| 308 |
+
<span class="rahyar-price">{st.session_state.price:,} تومان</span>
|
| 309 |
+
</div>
|
| 310 |
</div>
|
| 311 |
+
""", unsafe_allow_html=True)
|
| 312 |
+
|
| 313 |
show_explanation(st.session_state.scenario_type)
|
| 314 |
|
| 315 |
if st.button("درخواست راهیار", key="request_btn", type="primary"):
|