Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from traffic_logic import get_next_green
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="Smart Traffic Light System", layout="wide")
|
| 5 |
+
st.title("🚦 Smart Traffic Light Simulation")
|
| 6 |
+
|
| 7 |
+
st.sidebar.header("Vehicle Count per Road")
|
| 8 |
+
north = st.sidebar.slider("North Road", 0, 50, 10)
|
| 9 |
+
east = st.sidebar.slider("East Road", 0, 50, 20)
|
| 10 |
+
south = st.sidebar.slider("South Road", 0, 50, 5)
|
| 11 |
+
west = st.sidebar.slider("West Road", 0, 50, 15)
|
| 12 |
+
|
| 13 |
+
vehicle_counts = {'North': north, 'East': east, 'South': south, 'West': west}
|
| 14 |
+
next_green = get_next_green(vehicle_counts)
|
| 15 |
+
|
| 16 |
+
st.subheader("Traffic Light Status")
|
| 17 |
+
|
| 18 |
+
cols = st.columns(4)
|
| 19 |
+
for i, (road, count) in enumerate(vehicle_counts.items()):
|
| 20 |
+
light_color = "🟢 Green" if road == next_green else "🔴 Red"
|
| 21 |
+
cols[i].metric(label=f"{road} Road", value=f"{count} vehicles", delta=light_color)
|