Benny-Tang commited on
Commit
c80b5e5
·
verified ·
1 Parent(s): 625aacf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -25,7 +25,46 @@ def init_db():
25
  conn.commit()
26
  conn.close()
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  init_db()
 
29
 
30
  # ------------------ Police Functions ------------------
31
  def police_create_case(citizen_name, fine_amount, description, police_evidence):
@@ -174,3 +213,4 @@ with gr.Blocks() as demo:
174
  demo.launch()
175
 
176
 
 
 
25
  conn.commit()
26
  conn.close()
27
 
28
+ def seed_mock_data():
29
+ conn = sqlite3.connect(DB_FILE)
30
+ c = conn.cursor()
31
+ c.execute("SELECT COUNT(*) FROM cases")
32
+ count = c.fetchone()[0]
33
+
34
+ if count == 0:
35
+ cases = [
36
+ (
37
+ "Alice Johnson", 100.0, "Speeding in a 50 km/h zone",
38
+ "evidence_photo_speed.png",
39
+ None, None, "Pending Payment",
40
+ datetime.now().strftime("%Y-%m-%d %H:%M:%S")
41
+ ),
42
+ (
43
+ "Bob Smith", 250.0, "Running a red light",
44
+ "evidence_redlight_cam.jpg",
45
+ "I crossed on yellow, not red", "appeal_photo.jpg", "Appealed",
46
+ datetime.now().strftime("%Y-%m-%d %H:%M:%S")
47
+ ),
48
+ (
49
+ "Charlie Lee", 75.0, "Illegal parking",
50
+ "evidence_parking.jpg",
51
+ None, None, "Fine Paid",
52
+ datetime.now().strftime("%Y-%m-%d %H:%M:%S")
53
+ ),
54
+ ]
55
+
56
+ c.executemany("""
57
+ INSERT INTO cases (
58
+ citizen_name, fine_amount, description, police_evidence,
59
+ citizen_appeal, citizen_evidence, status, created_at
60
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
61
+ """, cases)
62
+ conn.commit()
63
+
64
+ conn.close()
65
+
66
  init_db()
67
+ seed_mock_data()
68
 
69
  # ------------------ Police Functions ------------------
70
  def police_create_case(citizen_name, fine_amount, description, police_evidence):
 
213
  demo.launch()
214
 
215
 
216
+