What's the best way to get continuous data from another program in Django?
<p>Here's the setup: On a single-board computer with a very rudimentary linux I'm running a <code>Django app</code>. This app is, when a button is pressed or as a response to the data described below, supposed to call either a function from a library written in <code>C</code>, or a compiled <code>C</code> program, to write data to system memory at a specified address, poke/peek like. (<code>Python</code> doesn't seem to be able to do that natively).<br>
The <code>Django</code> app should also display data, continuously, which is being read from the memory from the same library / program.</p>

<p>My question now is how to even begin with setting up the scenario described above. Is this even possible with a web app? Is a <code>Django</code> or more fundamentally any web framework even the right approach here? I'm at a bit of a loss here, since I've spent quite a few hours now trying to figure out how to do this while not getting the most basic starting point...</p>

<hr>

<p>Disclaimer: I'm pretty new to the entire web framework thing, and more importantly web development in general, so sorry if this is a <em>bad</em> question as in, I could have easily found information on this topic online, but I couldn't really find a good starting point on this.</p>

<p>I wanted to add a comment but not enough space... anyway</p>

<p>You can write a native extension in C for Python that could do what you need, check <a href="https://docs.python.org/2/extending/extending.html" rel="nofollow">this</a>.</p>

<p>Now for the fact of <em>displaying data continuously</em> this is kind of vague, if this C library is switching this hypothetical address, very often and very fast you have to update a browser client as fast as possible.</p>

<p>I think <a href="https://en.wikipedia.org/wiki/WebSocket" rel="nofollow">websockets</a> would do the trick but they are js related, so I think NodeJs would be a better candidate for the server side of your application instead of Django.</p>

<p>If you want to stick to Django you can also expose an URL with the generated address value and have a webpage continuously (with a little <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval" rel="nofollow">Interval</a>) checking that URL using a simple ajax call, kind of ugly and inefficient but would work.</p>

<p>Anyway IMHO your best bet is for websockets because with them you have a fullduplex communication between client and server.</p>

<p>Good Luck with your project.</p>

<p>Info:</p>

<p><a href="https://github.com/stephenmcd/django-socketio" rel="nofollow">Websockets in Django with socket.io</a></p>

<p><a href="http://socket.io/" rel="nofollow">Nodejs socket.io</a></p>

python django shared-memory web-frameworks