johnpaulbin commited on
Commit
3a12425
·
verified ·
1 Parent(s): d2a2b03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -41
app.py CHANGED
@@ -8,6 +8,7 @@ import re
8
  import emoji
9
  import queue
10
  import threading
 
11
 
12
  app = Flask(__name__)
13
  message_queue = queue.Queue()
@@ -68,62 +69,32 @@ def index():
68
  <html>
69
  <head>
70
  <title>Toki Pona Live Stream</title>
71
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
72
  <style>
73
  body {
74
- font-family: 'Inter', sans-serif;
75
  max-width: 800px;
76
  margin: 0 auto;
77
  padding: 20px;
78
  background-color: #f5f5f5;
79
  }
80
- h1 {
81
- color: #1a73e8;
82
- text-align: center;
83
- margin-bottom: 30px;
84
- }
85
- #messages {
86
- display: flex;
87
- flex-direction: column-reverse;
88
- }
89
  .message {
90
  background: white;
91
- padding: 20px;
92
  margin: 10px 0;
93
- border-radius: 10px;
94
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
95
- transition: transform 0.2s;
96
- }
97
- .message:hover {
98
- transform: translateY(-2px);
99
- box-shadow: 0 4px 8px rgba(0,0,0,0.15);
100
  }
101
- .message p {
102
- margin: 0 0 10px 0;
103
- line-height: 1.5;
104
- }
105
- .message a {
106
- color: #1a73e8;
107
  text-decoration: none;
108
- font-size: 0.9em;
109
- }
110
- .message a:hover {
111
- text-decoration: underline;
112
  }
113
- .header {
114
- background: white;
115
- padding: 20px;
116
- border-radius: 10px;
117
- margin-bottom: 20px;
118
  text-align: center;
119
  }
120
  </style>
121
  </head>
122
  <body>
123
- <div class="header">
124
- <h1>Toki Pona Live Stream</h1>
125
- <p>Live feed of Toki Pona messages from Bluesky</p>
126
- </div>
127
  <div id="messages"></div>
128
 
129
  <script>
@@ -136,11 +107,10 @@ def index():
136
  messageDiv.className = 'message';
137
  messageDiv.innerHTML = `
138
  <p>${data.text}</p>
139
- <a href="${data.url}" target="_blank">View on Bluesky →</a>
140
  `;
141
  messages.insertBefore(messageDiv, messages.firstChild);
142
 
143
- // Keep only the last 50 messages
144
  if (messages.children.length > 50) {
145
  messages.removeChild(messages.lastChild);
146
  }
@@ -156,4 +126,5 @@ def stream():
156
  if __name__ == '__main__':
157
  # Start the firehose processing in a separate thread
158
  threading.Thread(target=process_firehose, daemon=True).start()
159
- app.run(debug=True, host="0.0.0.0", port=7860)
 
 
8
  import emoji
9
  import queue
10
  import threading
11
+ from werkzeug.serving import run_simple
12
 
13
  app = Flask(__name__)
14
  message_queue = queue.Queue()
 
69
  <html>
70
  <head>
71
  <title>Toki Pona Live Stream</title>
 
72
  <style>
73
  body {
74
+ font-family: Arial, sans-serif;
75
  max-width: 800px;
76
  margin: 0 auto;
77
  padding: 20px;
78
  background-color: #f5f5f5;
79
  }
 
 
 
 
 
 
 
 
 
80
  .message {
81
  background: white;
82
+ padding: 15px;
83
  margin: 10px 0;
84
+ border-radius: 5px;
85
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
 
 
 
 
 
86
  }
87
+ a {
88
+ color: #0066cc;
 
 
 
 
89
  text-decoration: none;
 
 
 
 
90
  }
91
+ h1 {
 
 
 
 
92
  text-align: center;
93
  }
94
  </style>
95
  </head>
96
  <body>
97
+ <h1>Toki Pona Live Stream</h1>
 
 
 
98
  <div id="messages"></div>
99
 
100
  <script>
 
107
  messageDiv.className = 'message';
108
  messageDiv.innerHTML = `
109
  <p>${data.text}</p>
110
+ <a href="${data.url}" target="_blank">View on Bluesky</a>
111
  `;
112
  messages.insertBefore(messageDiv, messages.firstChild);
113
 
 
114
  if (messages.children.length > 50) {
115
  messages.removeChild(messages.lastChild);
116
  }
 
126
  if __name__ == '__main__':
127
  # Start the firehose processing in a separate thread
128
  threading.Thread(target=process_firehose, daemon=True).start()
129
+ # Use run_simple instead of app.run
130
+ run_simple('localhost', 7860, app, use_reloader=True, use_debugger=True)