I have a problem.
I want to send gcode to the biobot via the cmd command line through the repetier server by running the Python program code:
using instruction : python3 send_to_biobot.py
import requests
import os
def send_gcode_to_repetier_server(server_url, api_key, printer_slug, gcode_file_path):
"""Wysyła plik G-code do Repetier-Server i automatycznie rozpoczyna drukowanie."""
upload_url = f"{server_url}/printer/upload_job/{printer_slug}"
print(upload_url)
params = {
'apikey': api_key,
'autostart': '1' # Ustawia automatyczne rozpoczęcie drukowania
}
try:
if not os.path.exists(gcode_file_path):
raise FileNotFoundError(f"Plik '{gcode_file_path}' nie został znaleziony.")
with open(gcode_file_path, 'rb') as f:
files = {'file': (os.path.basename(gcode_file_path), f)}
print(f"Wysyłanie pliku '{gcode_file_path}' do Repetier-Server...")
response = requests.post(upload_url, params=params, files=files)
if response.status_code == 200:
print("Plik G-code został pomyślnie wgrany.")
print("Drukowanie rozpoczęło się automatycznie.")
else:
print(f"Błąd wysyłania: {response.status_code}")
print(f"Treść odpowiedzi: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Błąd połączenia z Repetier-Server: {e}")
except FileNotFoundError as e:
print(e)
Użycie funkcji
SERVER_URL = "http://localhost:3344"
API_KEY = "b4b6dbb4-2f1c-4afb-82ba-e7a02f41afb9" # Pamiętaj o wstawieniu swojego klucza API
PRINTER_SLUG = "drukarka"
GCODE_FILE = "C:/Users/gkad2021/Desktop/plik.gcode"
there is a message in cmd : The requested feature requires a user session with adequate permissions.
Please help what i need to do . I have looking in localhost:3344 and put apikey
send_gcode_to_repetier_server(SERVER_URL, API_KEY, PRINTER_SLUG, GCODE_FILE)