Grafic Temperatura Frigider Magazin Alimentar -

@app.route('/api/log', methods=['POST']) def log_temp(): fridge_id = request.json['fridge_id'] temp = request.json['temperature'] conn = sqlite3.connect('fridge.db') c = conn.cursor() c.execute("INSERT INTO temperature_logs (fridge_id, temp, recorded_at) VALUES (?,?,?)", (fridge_id, temp, datetime.now().isoformat())) conn.commit() conn.close() return jsonify('status': 'ok')

if == ' main ': init_db() app.run(debug=True) 4. Frontend (HTML + Chart.js) templates/graph.html <!DOCTYPE html> <html> <head> <title>Refrigerator Temperature Graph | Food Store</title> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body font-family: Arial; padding: 20px; background: #f4f7fc; .card background: white; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); h2 color: #1e466e; canvas max-height: 400px; width: 100%; .violation color: red; font-weight: bold; .safe color: green; select, button padding: 8px 12px; margin: 5px; font-size: 1rem; </style> </head> <body> <div class="card"> <h2>📊 Temperature Graph – Food Store Refrigerator</h2> <label>Select Fridge: </label> <select id="fridgeSelect"> <option value="1">Dairy Cooler (0°C..4°C)</option> </select> <label>Period: </label> <select id="periodSelect"> <option value="6">Last 6 hours</option> <option value="24" selected>Last 24 hours</option> <option value="48">Last 48 hours</option> </select> <button id="refreshBtn">🔄 Refresh Graph</button> <div style="margin-top: 10px;"> <span class="safe">✅ Safe zone (0°C – 4°C)</span>  |  <span class="violation">⚠️ Violation (>4°C or <0°C)</span> </div> </div> <div class="card"> <canvas id="tempChart" width="800" height="400"></canvas> </div> <script> let chart; grafic temperatura frigider magazin alimentar

@app.route('/') def index(): return render_template('graph.html') recorded_at) VALUES (?