Discord Bot – die besten Beiträge

Raspberry PI Flask-404 Not Found?

Hallo!

Ich habe das programmiert. Es wird jede Sekunde die Temperatur von der CPU ausgelesen. Jetzt möchte ich Flask einbauen, damit ich mit mehreren PC's darauf zugreifen kann. Aber es funktioniert nicht. Warum?

from flask import Flask, jsonify
import subprocess
import time
import os
from colorama import Fore, Style

app = Flask(__name__)

@app.route("/temp")
def get_cpu_temperature():
  try:
    result = subprocess.run(['vcgencmd', 'measure_temp'], capture_output=True, text=True, check=True)
    temperature_str = result.stdout.strip()
    temperature = float(temperature_str[5:-2]) # Extrahiere die Temperatur aus dem String
    return temperature
  except subprocess.CalledProcessError as e:
    print(f"Fehler beim Ausführen des Befehls: {e}")
    return None

def print_colored_temperature(temperature):
  if temperature is not None:
    if temperature > 49.9:
      print(f"{Fore.RED}Temperatur: {temperature}°C{Style.RESET_ALL}")
    else:
      print(f"Temperatur: {temperature}°C")
  else:
    print("Fehler beim Lesen der CPU-Temperatur.")

def main():
  try:
    while True:
      temperature = get_cpu_temperature()
      print_colored_temperature(temperature)
      time.sleep(1)
      os.system('clear')
  except KeyboardInterrupt:
    print("Programm wurde durch den Benutzer unterbrochen.")
  except Exception as e:
    print(f"Ein Fehler ist aufgetreten: {e}")
     
     


if __name__ == '__main__':
  app.run(host="0.0.0.0")

if __name__ == '__main__':
  main()
  import sys
  sys.exit(main(sys.argv))  
HTML, Code, Programmiersprache, Python, Python 3, Pycharm, Discord, Flask, Discord Bot, ChatGPT

Nodejs mariadb Column count doesn't match value count at row 1?

meine datenbank hat 4 spalten aber ich setze nur 3 ein weil die letzte eine auto_increment spalte ist,

ich nutze nodejs mit mariadb und habe folgende fehlermeldung beim daten einsetzen:

/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/misc/errors.js:64
  return new SqlError(msg, sql, fatal, info, sqlState, errno, additionalStack, addHeader);
         ^

SqlError: (conn=2420, no: 1136, SQLState: 21S01) Column count doesn't match value count at row 1
sql: INSERT INTO thread value (no, head, ts) - parameters:['1171187570193989762','rrrrrrrrrrrrrrrr',1699303276347]
    at module.exports.createError (/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/misc/errors.js:64:10)
    at PacketNodeEncoded.readError (/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/io/packet.js:582:19)
    at Query.readResponsePacket (/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/cmd/parser.js:58:28)
    at PacketInputStream.receivePacketBasic (/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/io/packet-input-stream.js:85:9)
    at PacketInputStream.onData (/home/j44/Downloads/themer/tut/node_modules/mariadb/lib/io/packet-input-stream.js:135:20)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  sqlMessage: "Column count doesn't match value count at row 1",
  sql: "INSERT INTO thread value (no, head, ts) - parameters:['1171187570193989762','rrrrrrrrrrrrrrrr',1699303276347]",
  fatal: false,
  errno: 1136,
  sqlState: '21S01',
  code: 'ER_WRONG_VALUE_COUNT_ON_ROW'
}


SQL, programmieren, JavaScript, Datenbank, MySQL, node.js, Discord, Discord Bot

Meistgelesene Beiträge zum Thema Discord Bot