Download app.py from barkha2/Janseva: direct link, hf CLI and curl.
- Browser
- Download file 3.87 kB
-
https://huggingface.co/spaces/barkha2/Janseva/resolve/main/app.py
- Command line
-
hf download hf://spaces/barkha2/Janseva/app.py
-
curl -L -o app.py https://huggingface.co/spaces/barkha2/Janseva/resolve/main/app.py
3.87 kB
| # janseva_full.py | |
| import streamlit as st | |
| import pandas as pd | |
| import datetime | |
| # ------------------------------ | |
| # Page Config | |
| # ------------------------------ | |
| st.set_page_config( | |
| page_title="JanSeva Citizen Network", | |
| page_icon="π", | |
| layout="wide" | |
| ) | |
| # ------------------------------ | |
| # Initialize Database | |
| # ------------------------------ | |
| if "submissions" not in st.session_state: | |
| st.session_state.submissions = [] | |
| # ------------------------------ | |
| # Header | |
| # ------------------------------ | |
| st.title("π JanSeva Citizen Network") | |
| st.markdown(""" | |
| Submit your problem and proposed solution. | |
| Women & children contributions are highlighted π. | |
| Voting only activates after government implementation. | |
| """) | |
| # ------------------------------ | |
| # Submission Form | |
| # ------------------------------ | |
| with st.form("submission_form"): | |
| name = st.text_input("Your Name (optional for anonymity)") | |
| category = st.selectbox( | |
| "Category", | |
| ["Corruption", "Education", "Health", "Women Safety", "Children Welfare", "Infrastructure"] | |
| ) | |
| description = st.text_area("Describe your problem") | |
| solution = st.text_area("Propose your solution") | |
| is_women_or_child = st.checkbox("I am a woman or child contributor") | |
| submit = st.form_submit_button("Submit Problem & Solution") | |
| if submit: | |
| st.session_state.submissions.append({ | |
| "name": name if name else "Anonymous", | |
| "category": category, | |
| "description": description, | |
| "solution": solution, | |
| "highlight": is_women_or_child, | |
| "timestamp": datetime.datetime.now(), | |
| "status": "Pending Implementation", | |
| "vote_active": False, | |
| "votes": 0 | |
| }) | |
| st.success("β Submission recorded! Voting will activate after implementation.") | |
| # ------------------------------ | |
| # Admin Section (Simulate Implementation) | |
| # ------------------------------ | |
| st.header("π Admin Panel (Implementation)") | |
| st.markdown("For demo: Click 'Mark Implemented' to activate voting for a submission.") | |
| for idx, submission in enumerate(st.session_state.submissions): | |
| if submission["status"] == "Pending Implementation": | |
| if st.button(f"Mark Implemented: {submission['description'][:30]}...", key=f"imp{idx}"): | |
| st.session_state.submissions[idx]["status"] = "Implemented" | |
| st.session_state.submissions[idx]["vote_active"] = True | |
| st.success(f"Submission '{submission['description'][:30]}...' marked as Implemented!") | |
| # ------------------------------ | |
| # Voting Section | |
| # ------------------------------ | |
| st.header("π³ Vote for Implemented Solutions") | |
| for idx, submission in enumerate(st.session_state.submissions): | |
| if submission["vote_active"]: | |
| vote = st.button(f"Vote: {submission['description'][:50]}...", key=f"vote{idx}") | |
| if vote: | |
| st.session_state.submissions[idx]["votes"] += 1 | |
| st.success("β Your vote has been counted!") | |
| # ------------------------------ | |
| # Public Dashboard | |
| # ------------------------------ | |
| st.header("π Public Dashboard") | |
| if st.session_state.submissions: | |
| display_df = pd.DataFrame(st.session_state.submissions) | |
| display_df["highlighted"] = display_df["highlight"].apply(lambda x: "π" if x else "") | |
| display_df["timestamp"] = display_df["timestamp"].dt.strftime("%Y-%m-%d %H:%M") | |
| st.dataframe(display_df[["highlighted","category","description","solution","status","votes","timestamp"]]) | |
| else: | |
| st.info("No submissions yet. Be the first to contribute!") | |
| # ------------------------------ | |
| # Legal Disclaimer | |
| # ------------------------------ | |
| st.markdown(""" | |
| **Legal Disclaimer:** | |
| - All data is anonymized. | |
| - Offensive or illegal content will be removed. | |
| - Children submissions protected as per law. | |
| - Voting only activates after official implementation. | |
| """) | |