This commit is contained in:
Nathan-rek
2024-11-18 16:55:21 +01:00
parent ea2daaedb7
commit bb96bb4650
2 changed files with 1796 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ from flask import Flask, render_template, request
import sys import sys
import os import os
from streamer import stream_gcode from streamer import stream_gcode
from text_to_gcode import convert_text
import svgToGcode import svgToGcode
app = Flask(__name__) app = Flask(__name__)
@@ -71,9 +73,8 @@ def getGcode():
def getText(): def getText():
if request.method == "POST": if request.method == "POST":
txt = request.form["txt"].strip() txt = request.form["txt"].strip()
print(txt)
if txt: if txt:
# Découpe le texte en lignes de 20 caractères max
formatted_text = "" formatted_text = ""
current_line = "" current_line = ""
for word in txt.split(): for word in txt.split():
@@ -87,9 +88,18 @@ def getText():
if current_line.strip(): if current_line.strip():
formatted_text += current_line.strip() formatted_text += current_line.strip()
print("Original text:", txt)
print("Formatted text with line breaks:") print("Formatted text with line breaks:")
print(formatted_text) print(formatted_text)
gcode_output = convert_text(formatted_text)
print("G-code generated:")
print(gcode_output)
gcode_filename = "retourligne.gcode"
with open(gcode_filename, "w") as gcode_file:
gcode_file.write(gcode_output)
print(f"G-code saved to {gcode_filename}")
else: else:
print('empty text') print('empty text')

File diff suppressed because it is too large Load Diff