Spaces:
Runtime error
Runtime error
File size: 1,264 Bytes
956fdbb |
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 |
from flask import Flask, render_template
from flask_socketio import SocketIO
import threading
import time
import random
app = Flask(__name__)
socketio = SocketIO(app)
# Simulate real-time data updates
def update_data():
while True:
# Simulate data updates
data = {
'locations': {'Vehicle1': [random.uniform(40.7, 40.8), random.uniform(-74.0, -73.9)]},
'routes': ['Route1', 'Route2'],
'schedules': ['Schedule1', 'Schedule2'],
'pressures': {'Zone A': random.randint(20, 50), 'Zone B': random.randint(30, 60)}
}
socketio.emit('update_data', data)
time.sleep(5) # Update every 5 seconds
@app.route('/dashboard')
def dashboard():
return render_template('dashboard.html', map='Map Placeholder')
@app.route('/pressure')
def pressure():
pressures = {'Zone A': 30, 'Zone B': 45}
heatmap_img = 'Image Placeholder'
rewards = {'Vehicle1': 100, 'Vehicle2': 50}
assignments = {'Driver1': 'Zone A', 'Driver2': 'Zone B'}
return render_template('pressure.html', pressures=pressures, heatmap_img=heatmap_img, rewards=rewards, assignments=assignments)
if __name__ == '__main__':
threading.Thread(target=update_data).start()
socketio.run(app, debug=True) |