Sending Data from Python-Script to Browser (under xserver on Linux)
<p>I need some ideas about how to send Data from a Python Script to a Web browser.
The Script (and the browser) runs under xServer Environment in Linux (Raspbian on Raspberry Pi).</p>

<p>The Python script handles receiving data over a serial port (in this case it's just a number scanned from a barcode reader on a manufacturing line). After the data is received it gets send to a backend system on another computer (via Webservices).</p>

<p>Now the problem is that the customer maybe wants a HTML5 Frontend to scan those numbers manually. So I think the easiest way would be that the HTML5 Webpage does the sending of the barcode number to the backend. But how do I get the number from the serial port to the browser?</p>

<p>One solution I'm considering is using PyAutoGUI and just simply type the barcode in the active field. But I don't like it because if anyone moves the focus away from the HTML5-Barcode Field those numbers gets lost in nirvana.</p>

<p>The next solution is that Python sends the number to the backend, and that the HTML5 Frontend polls the backend for new numbers. (Websocket would maybe be another option which has less latency). 
I don't like this idea because the number would not be there instantly.</p>

<p>So has anyone other suggestions how to make sure that I'm typing these numbers in the exact right field in the browser? This system would be locked down to the bare minimum so we can make sure that there is no other webpage open.</p>

<p>Any really tricky ideas?</p>

<p>Using PyAutoGui, making a screenshot of the field and searching this on browser window is one idea. But maybe I'm thinking way to complicated...</p>

<p>Saving the number in a file and opening it in the browser (from Javascript) would be another idea. But I think Javascript is too locked down for that, or am I wrong?</p>

<p>Thomas</p>