Spaces:
Runtime error
Runtime error
File size: 1,154 Bytes
7d537ca |
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 |
from flask import Flask, render_template, jsonify
from flask_socketio import SocketIO
import threading
import time
app = Flask(__name__)
socketio = SocketIO(app)
# Simulate real-time updates
def update_data():
while True:
# Simulate data updates
data = {
'locations': {'Vehicle1': [40.7128, -74.0060], 'Vehicle2': [34.0522, -118.2437]},
'routes': ['Route1', 'Route2'],
'schedules': ['Schedule1', 'Schedule2']
}
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) |