Allowing someone external 🖥️ to connect to my line-us

I was wondering if it was possible to allow others to connect to my line-us and send drawings automatically.
So it would draw as soon as someone else presses ‘send’ of their drawing.
Maybe even if I created a web canvas for drawing, not using the app, then hit send it would then print out.
Do I need to make a special websocket or something?
All new to coding. :desktop_computer: Any help would be great.
Thanks in advance :grin:

ChatGPT seems to think the answer is the following:

Yes, it is possible to allow others to connect to your Line-us and send drawings automatically. One way to achieve this is by creating a web application that allows users to draw on a canvas and sends the drawing to your Line-us device when the user clicks on the “send” button.

To accomplish this, you would need to do the following:

  1. Set up a server that can communicate with your Line-us device. You can use a Raspberry Pi or a similar device to act as the server.

  2. Create a web application that includes a canvas element for users to draw on. You can use JavaScript to handle user input and capture the drawing.

  3. When the user clicks on the “send” button, the JavaScript code should send the drawing data to the server using an HTTP request.

  4. The server should receive the drawing data, format it in a way that is compatible with the Line-us API, and send it to the Line-us device using a TCP/IP socket connection.

Here is an example of JavaScript code that captures the drawing data and sends it to the server using an HTTP request:

const canvas = document.getElementById(“canvas”);
const context = canvas.getContext(“2d”);

document.getElementById(“send-button”).addEventListener(“click”, () => {
const imageData = canvas.toDataURL(“image/png”);
fetch("/draw", {
method: “POST”,
headers: {
“Content-Type”: “application/json”,
},
body: JSON.stringify({ imageData }),
});
});

In this example, the canvas element is used to capture the drawing data. When the user clicks on the “send” button, the toDataURL method is used to convert the drawing to a PNG image, which is then sent to the server using an HTTP POST request.

On the server side, you would need to handle the HTTP request and send the drawing data to the Line-us device. Here is an example of Python code that does this:

import socket

HOST = ‘192.168.1.1’ # IP address of the Line-us device
PORT = 1337 # Port number used by the Line-us API

def send_drawing_to_line_us(image_data):
# Convert the image data to a format compatible with the Line-us API
# …

# Open a TCP/IP socket connection to the Line-us device
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))

    # Send the formatted drawing data to the Line-us device
    # ...

Handle HTTP POST requests to the /draw endpoint

@app.route(’/draw’, methods=[‘POST’])
def draw():
image_data = request.json[‘imageData’]
send_drawing_to_line_us(image_data)
return ‘’

In this example, the send_drawing_to_line_us function is used to format the drawing data in a way that is compatible with the Line-us API and send it to the Line-us device using a TCP/IP socket connection. The draw function is used to handle HTTP POST requests to the /draw endpoint and call the send_drawing_to_line_us function to send the drawing data to the Line-us device.

Note that this is just a basic example, and you will need to modify the code to suit your specific needs. You may also need to set up authentication and authorization to prevent unauthorized users from accessing your Line-us device.

Not a bad attempt by ChatGPT actually! It got the correct port which is quite impressive.

Are you looking to have people on the same WiFi as you access your Line-us or are you wanting to get access over the internet?

1 Like

I was hoping to be able to allow others to have access over the internet :slightly_smiling_face:
Do you @Line-us have any thoughts or ideas on what would be the best way to do that?

Do you have any tips or links to anywhere where this might have been done before? Or do you know how I’d go about doing it?