Spaces:
Sleeping
Sleeping
File size: 14,329 Bytes
314fac4 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 ea1092e 65bd2d8 8ca2f9f 65bd2d8 314fac4 65bd2d8 41d5de2 314fac4 431d541 41d5de2 2b8aece 65bd2d8 41d5de2 74bd5a5 65bd2d8 41d5de2 74bd5a5 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 74bd5a5 65bd2d8 74bd5a5 41d5de2 74bd5a5 65bd2d8 41d5de2 74bd5a5 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 74bd5a5 65bd2d8 41d5de2 65bd2d8 74bd5a5 65bd2d8 41d5de2 65bd2d8 74bd5a5 41d5de2 74bd5a5 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 74bd5a5 65bd2d8 431d541 65bd2d8 41d5de2 65bd2d8 314fac4 65bd2d8 314fac4 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 06d7e14 41d5de2 06d7e14 41d5de2 2b8aece 65bd2d8 41d5de2 65bd2d8 74bd5a5 41d5de2 74bd5a5 65bd2d8 41d5de2 74bd5a5 65bd2d8 41d5de2 4ad4653 41d5de2 4ad4653 41d5de2 65bd2d8 41d5de2 4ad4653 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 4ad4653 41d5de2 65bd2d8 41d5de2 65bd2d8 4ad4653 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 314fac4 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 65bd2d8 41d5de2 4ad4653 65bd2d8 |
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# app.py
import streamlit as st
import requests
import time
import plotly.express as px
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Set up Streamlit page
st.set_page_config(
page_title="Legal Rights Explorer",
page_icon="โ๏ธ",
layout="wide",
initial_sidebar_state="collapsed"
)
# Custom CSS for professional styling
st.markdown("""
<style>
:root {
--primary: #2c3e50;
--secondary: #3498db;
--accent: #e74c3c;
--light: #ecf0f1;
--dark: #2c3e50;
--success: #27ae60;
--card-shadow: 0 6px 20px rgba(0,0,0,0.1);
}
.stApp {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
color: #333;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.header {
background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
color: white;
padding: 1.8rem 2rem;
border-radius: 0 0 20px 20px;
box-shadow: var(--card-shadow);
margin-bottom: 2.5rem;
}
.card {
background: white;
border-radius: 15px;
padding: 1.8rem;
box-shadow: var(--card-shadow);
margin-bottom: 1.8rem;
transition: all 0.3s ease;
border-left: 4px solid var(--secondary);
}
.card:hover {
box-shadow: 0 12px 30px rgba(0,0,0,0.15);
transform: translateY(-5px);
}
.scenario-btn {
width: 100%;
padding: 1.1rem;
background: linear-gradient(135deg, var(--secondary) 0%, #2980b9 100%);
color: white;
border: none;
border-radius: 12px;
font-weight: 600;
margin: 0.7rem 0;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
padding-left: 20px;
font-size: 1.05rem;
}
.scenario-btn:hover {
background: linear-gradient(135deg, var(--primary) 0%, #2c3e50 100%);
transform: scale(1.02);
}
.response-card {
background: white;
border-left: 5px solid var(--success);
border-radius: 12px;
padding: 2rem;
margin-top: 2rem;
box-shadow: var(--card-shadow);
animation: fadeIn 0.6s ease;
}
.country-card {
display: flex;
align-items: center;
gap: 15px;
padding: 1.2rem;
border-radius: 12px;
background: white;
box-shadow: var(--card-shadow);
margin-bottom: 15px;
cursor: pointer;
transition: all 0.3s ease;
}
.country-card:hover {
transform: translateX(5px);
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.country-card.selected {
background: linear-gradient(135deg, var(--light) 0%, var(--secondary) 100%);
border-left: 4px solid var(--accent);
}
.footer {
text-align: center;
padding: 2rem;
margin-top: 3rem;
color: var(--dark);
font-size: 0.95rem;
background: rgba(236, 240, 241, 0.7);
border-radius: 15px;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
.header {
padding: 1.3rem;
}
.card {
padding: 1.3rem;
}
}
</style>
""", unsafe_allow_html=True)
# Country data with flags
COUNTRIES = {
"๐บ๐ธ United States": "US",
"๐ฌ๐ง United Kingdom": "UK",
"๐จ๐ฆ Canada": "CA",
"๐ฆ๐บ Australia": "AU",
"๐ฎ๐ณ India": "IN",
"๐ฉ๐ช Germany": "DE",
"๐ซ๐ท France": "FR",
"๐ฏ๐ต Japan": "JP",
"๐ง๐ท Brazil": "BR",
"๐ฟ๐ฆ South Africa": "ZA",
"๐ช๐ธ Spain": "ES",
"๐ฎ๐น Italy": "IT"
}
# Common legal scenarios
SCENARIOS = [
"Traffic Stop by Police",
"Workplace Discrimination",
"Rental Housing Issues",
"Medical Emergency Rights",
"Consumer Protection",
"Arrest or Detention",
"Border Crossing",
"Online Privacy",
"Employment Termination",
"Debt Collection",
"Freedom of Speech",
"Immigration Rights"
]
# Simulated API function
def get_legal_rights(country, scenario):
"""Simulate API response with country-specific legal rights"""
# In a real implementation, this would call an external API
# For this demo, we'll return simulated responses
# Simulate API delay
time.sleep(1.5)
# Base rights that apply to most countries
base_rights = [
"Right to remain silent",
"Right to legal representation",
"Right to be treated with dignity and respect",
"Right to understand the charges against you",
"Right to a fair and impartial process"
]
# Country-specific additions
country_specific = {
"US": [
"Right to refuse unwarranted searches (4th Amendment)",
"Right to due process (5th Amendment)",
"Right to a speedy and public trial (6th Amendment)"
],
"UK": [
"Right to legal advice under the Police and Criminal Evidence Act",
"Right to have someone informed of your arrest",
"Protection under the Human Rights Act 1998"
],
"CA": [
"Right to be informed of the reason for detention (Charter of Rights)",
"Right to retain and instruct counsel without delay",
"Right to habeas corpus"
],
"AU": [
"Right to silence during police questioning",
"Right to communicate with a friend or relative",
"Protection under the Australian Human Rights Commission Act"
],
"IN": [
"Right to free legal aid under Article 39A of the Constitution",
"Protection against self-incrimination (Article 20)",
"Right to be informed of grounds for arrest (Article 22)"
]
}
# Scenario-specific additions
scenario_specific = {
"Traffic Stop by Police": [
"Right to see official identification",
"Right to know the reason for the stop",
"Right to refuse a search without probable cause",
"Right to record the interaction"
],
"Workplace Discrimination": [
"Right to a discrimination-free workplace",
"Right to report without retaliation",
"Right to reasonable accommodations",
"Right to equal pay for equal work"
],
"Medical Emergency Rights": [
"Right to emergency treatment regardless of insurance",
"Right to informed consent",
"Right to access medical records",
"Right to privacy of health information"
],
"Arrest or Detention": [
"Right to be informed of charges",
"Right to contact your embassy if foreign national",
"Right to humane treatment",
"Right to challenge the lawfulness of detention"
]
}
# Combine rights based on country and scenario
rights = base_rights.copy()
if country in country_specific:
rights.extend(country_specific[country])
for key, value in scenario_specific.items():
if key in scenario:
rights.extend(value)
break
# Format the response
response = f"## ๐ Your Rights in {country}\n"
response += f"### Situation: {scenario}\n\n"
response += "Based on the laws of your selected country, you have the following rights:\n\n"
for i, right in enumerate(set(rights), 1):
response += f"โ
**{right}**\n\n"
response += "\n**Important Notes:**\n"
response += "- This information is for educational purposes only\n"
response += "- Laws vary by jurisdiction and circumstances\n"
response += "- Consult a qualified attorney for legal advice\n"
return response
# Main app
def main():
# Header section
st.markdown("""
<div class="header">
<h1 style="margin:0;font-size:2.3rem;">Legal Rights Explorer</h1>
<p style="margin:0;font-size:1.2rem;opacity:0.9;">Know your rights in any situation, anywhere in the world</p>
</div>
""", unsafe_allow_html=True)
# Initialize session state
if 'selected_country' not in st.session_state:
st.session_state.selected_country = "๐บ๐ธ United States"
if 'selected_scenario' not in st.session_state:
st.session_state.selected_scenario = None
# Main content columns
col1, col2 = st.columns([1, 2], gap="large")
with col1:
st.markdown("### ๐ Select Your Country")
st.markdown("Choose your country to see jurisdiction-specific rights information")
# Country selection cards
for country_display in COUNTRIES.keys():
is_selected = st.session_state.selected_country == country_display
card_class = "country-card selected" if is_selected else "country-card"
st.markdown(f"""
<div class="{card_class}" onclick="selectCountry('{country_display}')">
<span style="font-size:1.8rem;">{country_display.split()[0]}</span>
<span style="font-weight:500;">{country_display.split(' ', 1)[1]}</span>
</div>
""", unsafe_allow_html=True)
# Country visualization
st.markdown("### ๐ Global Rights Index")
countries = list(COUNTRIES.values())
awareness = [92, 89, 87, 85, 82, 88, 86, 84, 79, 81, 85, 83] # Simulated data
fig = px.bar(
x=countries,
y=awareness,
labels={'x': 'Country', 'y': 'Rights Awareness'},
color=awareness,
color_continuous_scale='Blues',
height=300
)
fig.update_layout(
plot_bgcolor='rgba(0,0,0,0)',
paper_bgcolor='rgba(0,0,0,0)',
margin=dict(l=0, r=0, t=30, b=0)
)
st.plotly_chart(fig, use_container_width=True)
# Legal resources
with st.expander("๐ Legal Resources"):
st.markdown("""
- [United Nations Human Rights](https://www.ohchr.org/)
- [International Justice Resource Center](https://ijrcenter.org/)
- [Global Legal Information Network](https://www.loc.gov/law/help/legal-info.php)
- [World Legal Information Institute](https://www.worldlii.org/)
""")
with col2:
st.markdown("### ๐จ Select a Legal Scenario")
st.markdown("Choose a situation to understand your rights and protections")
# Create buttons for each scenario
cols = st.columns(2)
for i, scenario in enumerate(SCENARIOS):
with cols[i % 2]:
if st.button(
f"**{scenario}**",
key=scenario,
use_container_width=True,
help=f"Click to see your rights for {scenario}"
):
st.session_state.selected_scenario = scenario
# Custom scenario input
custom_scenario = st.text_input("**Or describe your specific situation:**", placeholder="e.g., 'Rights during home search'")
if custom_scenario:
st.session_state.selected_scenario = custom_scenario
# Response area
st.markdown("### โ๏ธ Your Legal Rights")
if st.session_state.selected_scenario:
country_code = COUNTRIES[st.session_state.selected_country]
with st.spinner(f"Analyzing your rights for {st.session_state.selected_scenario} in {country_code}..."):
response = get_legal_rights(
country_code,
st.session_state.selected_scenario
)
if response:
st.markdown(f'<div class="response-card">{response}</div>', unsafe_allow_html=True)
else:
st.error("Failed to get response. Please try again.")
else:
st.info("Please select a legal scenario to see your rights information")
st.image("https://images.unsplash.com/photo-1589391886645-d51941baf7fb?auto=format&fit=crop&w=600&h=400",
caption="Know Your Rights, Exercise Your Freedom")
st.markdown("""
<div class="card">
<h3>Why Know Your Rights?</h3>
<p>Understanding your legal rights empowers you to:</p>
<ul>
<li>Protect yourself in difficult situations</li>
<li>Make informed decisions when facing legal issues</li>
<li>Prevent exploitation and rights violations</li>
<li>Access justice when your rights are infringed</li>
<li>Confidently navigate complex legal systems</li>
</ul>
<p style="margin-top:15px;font-style:italic;">"Knowledge of the law is the first defense against injustice."</p>
</div>
""", unsafe_allow_html=True)
# Footer
st.markdown("""
<div class="footer">
<p>Legal Rights Explorer | ยฉ 2023 | For Educational Purposes Only | Not Legal Advice</p>
<p>Always consult a qualified attorney in your jurisdiction for your specific legal situation</p>
</div>
""", unsafe_allow_html=True)
# JavaScript for country selection
st.markdown("""
<script>
function selectCountry(country) {
window.parent.document.querySelectorAll("button[kind='secondary']")[0].click();
setTimeout(function() {
const countryButtons = window.parent.document.querySelectorAll("button[kind='secondary']");
for (let btn of countryButtons) {
if (btn.innerText.includes(country)) {
btn.click();
break;
}
}
}, 100);
}
</script>
""", unsafe_allow_html=True)
if __name__ == "__main__":
main() |