DJ
Didier Juges
Sun, Jul 5, 2015 7:13 PM
I have been working on and off on that kind of project for a while.
One type of issue you have when trying to control hardware from a web page is that any hardware access from a web server poses many issues, such as permissions and the fact that web servers are basically stateless and many are multitasking.
What happens if your web page (or the python script behind it) tries to send data on a serial port (for instance) and another request for the same thing comes along?
The current approach I am using is to have a separate process that maintains the device status in files that be easily accessed by the web server, so that simple status requests can be serviced immediately without needing to query the device each time, and use a fifo to pipe commands between the web page script and the process. The process is the only one that talks to the hardware, so there is no contention.
On the client side, you can use Ajax to keep the web page updated with fresh data without reloading everything each time. It is JavaScript, but there is not too much of it. That part is relatively easy, unless you want to make it really pretty. In that case, it takes a different set of skills (art major with CSS experience...)
Here is a demo:
http://www.ko4bb.com/AjaxDemo/x-web.html
The back end of that runs on php, but it could be python just the same.
Obviously failing the "pretty" test :)
Didier KO4BB
On July 4, 2015 8:13:06 AM CDT, Jim Lux jimlux@earthlink.net wrote:
I've got a project I'm working on to make a sophisticated sundial with
moving mirrors. I've got a batch of Arduinos that move the mirrors to
the appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun angle
based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be manipulated
by a mobile device using a browser.
One way I can think of is to run some sort of limited web server. there
are a couple that come with the beaglebone, including the python
"simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the
other code running.
I've done this kind of thing where the one task goes out and updates
files in the tree that's being served by the web server, and that works
fine for "status display" kinds of things that don't update very
quickly. It's also nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by
having the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for
specific URLs requested, and then fire off some custom code to do what
I
want?
I'm not particularly interested in javascript, and would prefer python.
Or are there libraries that make this more cookbook? (the little
"getting started with beaglebone" book talks about flask)
There's quite a few websites out there where someone has done some sort
of "home automation", but they tend to be a bit light on the analysis
of
pros and cons of implementation architectures: "I built X using Y and Z
and it sort of works".
Actually, along a similar line.. my "solar position" code isn't very
pretty (it's sort of replicating some code I wrote in Basic a long time
ago, with some changes from stuff I cribbed from ccmatlab). If someone
knows of a python package that just "does this", I'd love to hear about
it. Either Az El, or X,Y,Z in ECI or ECF would do.
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to
https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
--
Sent from my Motorola Droid Razr HD 4G LTE wireless tracker while I do other things.
I have been working on and off on that kind of project for a while.
One type of issue you have when trying to control hardware from a web page is that any hardware access from a web server poses many issues, such as permissions and the fact that web servers are basically stateless and many are multitasking.
What happens if your web page (or the python script behind it) tries to send data on a serial port (for instance) and another request for the same thing comes along?
The current approach I am using is to have a separate process that maintains the device status in files that be easily accessed by the web server, so that simple status requests can be serviced immediately without needing to query the device each time, and use a fifo to pipe commands between the web page script and the process. The process is the only one that talks to the hardware, so there is no contention.
On the client side, you can use Ajax to keep the web page updated with fresh data without reloading everything each time. It is JavaScript, but there is not too much of it. That part is relatively easy, unless you want to make it really pretty. In that case, it takes a different set of skills (art major with CSS experience...)
Here is a demo:
http://www.ko4bb.com/AjaxDemo/x-web.html
The back end of that runs on php, but it could be python just the same.
Obviously failing the "pretty" test :)
Didier KO4BB
On July 4, 2015 8:13:06 AM CDT, Jim Lux <jimlux@earthlink.net> wrote:
>I've got a project I'm working on to make a sophisticated sundial with
>moving mirrors. I've got a batch of Arduinos that move the mirrors to
>the appropriate places, given the current sun angle, etc.
>
>I've got a beaglebone that runs some python code to calculate sun angle
>
>based on time
>
>The beaglebone will have a GPS feeding it to get time.
>
>BUT now, I'd like to add a web interface, so that it can be manipulated
>
>by a mobile device using a browser.
>
>One way I can think of is to run some sort of limited web server. there
>
>are a couple that come with the beaglebone, including the python
>"simplehttpserver".
>
>But I'm sort of stuck on the interface between the webserver and the
>other code running.
>
>I've done this kind of thing where the one task goes out and updates
>files in the tree that's being served by the web server, and that works
>
>fine for "status display" kinds of things that don't update very
>quickly. It's also nicely partitioned.
>
>but I want to be able to change the behavior of the system (e.g. by
>having the server respond to a PUT or something)
>
>Is the best scheme to go in and modify the webserver code to look for
>specific URLs requested, and then fire off some custom code to do what
>I
>want?
>
>I'm not particularly interested in javascript, and would prefer python.
>
>
>Or are there libraries that make this more cookbook? (the little
>"getting started with beaglebone" book talks about flask)
>
>There's quite a few websites out there where someone has done some sort
>
>of "home automation", but they tend to be a bit light on the analysis
>of
>pros and cons of implementation architectures: "I built X using Y and Z
>
>and it sort of works".
>
>
>Actually, along a similar line.. my "solar position" code isn't very
>pretty (it's sort of replicating some code I wrote in Basic a long time
>
>ago, with some changes from stuff I cribbed from ccmatlab). If someone
>
>knows of a python package that just "does this", I'd love to hear about
>
>it. Either Az El, or X,Y,Z in ECI or ECF would do.
>
>
>
>_______________________________________________
>time-nuts mailing list -- time-nuts@febo.com
>To unsubscribe, go to
>https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>and follow the instructions there.
--
Sent from my Motorola Droid Razr HD 4G LTE wireless tracker while I do other things.
CA
Chris Albertson
Mon, Jul 6, 2015 2:47 AM
Keep it simple, use a Cgi bin script. Your url is can be any executable.
Any language you like. The script can do anything and then it writes out
html to stdout. Simple enough. .
On Saturday, July 4, 2015, Jim Lux jimlux@earthlink.net wrote:
I've got a project I'm working on to make a sophisticated sundial with
moving mirrors. I've got a batch of Arduinos that move the mirrors to the
appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun angle
based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be manipulated by
a mobile device using a browser.
One way I can think of is to run some sort of limited web server. there
are a couple that come with the beaglebone, including the python
"simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the other
code running.
I've done this kind of thing where the one task goes out and updates files
in the tree that's being served by the web server, and that works fine for
"status display" kinds of things that don't update very quickly. It's also
nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by having
the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for
specific URLs requested, and then fire off some custom code to do what I
want?
I'm not particularly interested in javascript, and would prefer python.
Or are there libraries that make this more cookbook? (the little "getting
started with beaglebone" book talks about flask)
There's quite a few websites out there where someone has done some sort of
"home automation", but they tend to be a bit light on the analysis of pros
and cons of implementation architectures: "I built X using Y and Z and it
sort of works".
Actually, along a similar line.. my "solar position" code isn't very
pretty (it's sort of replicating some code I wrote in Basic a long time
ago, with some changes from stuff I cribbed from ccmatlab). If someone
knows of a python package that just "does this", I'd love to hear about
it. Either Az El, or X,Y,Z in ECI or ECF would do.
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to
https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
--
Chris Albertson
Redondo Beach, California
Keep it simple, use a Cgi bin script. Your url is can be any executable.
Any language you like. The script can do anything and then it writes out
html to stdout. Simple enough. .
On Saturday, July 4, 2015, Jim Lux <jimlux@earthlink.net> wrote:
> I've got a project I'm working on to make a sophisticated sundial with
> moving mirrors. I've got a batch of Arduinos that move the mirrors to the
> appropriate places, given the current sun angle, etc.
>
> I've got a beaglebone that runs some python code to calculate sun angle
> based on time
>
> The beaglebone will have a GPS feeding it to get time.
>
> BUT now, I'd like to add a web interface, so that it can be manipulated by
> a mobile device using a browser.
>
> One way I can think of is to run some sort of limited web server. there
> are a couple that come with the beaglebone, including the python
> "simplehttpserver".
>
> But I'm sort of stuck on the interface between the webserver and the other
> code running.
>
> I've done this kind of thing where the one task goes out and updates files
> in the tree that's being served by the web server, and that works fine for
> "status display" kinds of things that don't update very quickly. It's also
> nicely partitioned.
>
> but I want to be able to change the behavior of the system (e.g. by having
> the server respond to a PUT or something)
>
> Is the best scheme to go in and modify the webserver code to look for
> specific URLs requested, and then fire off some custom code to do what I
> want?
>
> I'm not particularly interested in javascript, and would prefer python.
>
>
> Or are there libraries that make this more cookbook? (the little "getting
> started with beaglebone" book talks about flask)
>
> There's quite a few websites out there where someone has done some sort of
> "home automation", but they tend to be a bit light on the analysis of pros
> and cons of implementation architectures: "I built X using Y and Z and it
> sort of works".
>
>
> Actually, along a similar line.. my "solar position" code isn't very
> pretty (it's sort of replicating some code I wrote in Basic a long time
> ago, with some changes from stuff I cribbed from ccmatlab). If someone
> knows of a python package that just "does this", I'd love to hear about
> it. Either Az El, or X,Y,Z in ECI or ECF would do.
>
>
>
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
>
--
Chris Albertson
Redondo Beach, California
TH
Tom Harris
Mon, Jul 6, 2015 10:19 PM
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
Tom Harris celephicus@gmail.com
On 4 July 2015 at 23:13, Jim Lux jimlux@earthlink.net wrote:
I've got a project I'm working on to make a sophisticated sundial with
moving mirrors. I've got a batch of Arduinos that move the mirrors to the
appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun angle
based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be manipulated by
a mobile device using a browser.
One way I can think of is to run some sort of limited web server. there
are a couple that come with the beaglebone, including the python
"simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the other
code running.
I've done this kind of thing where the one task goes out and updates files
in the tree that's being served by the web server, and that works fine for
"status display" kinds of things that don't update very quickly. It's also
nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by having
the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for
specific URLs requested, and then fire off some custom code to do what I
want?
I'm not particularly interested in javascript, and would prefer python.
Or are there libraries that make this more cookbook? (the little "getting
started with beaglebone" book talks about flask)
There's quite a few websites out there where someone has done some sort of
"home automation", but they tend to be a bit light on the analysis of pros
and cons of implementation architectures: "I built X using Y and Z and it
sort of works".
Actually, along a similar line.. my "solar position" code isn't very
pretty (it's sort of replicating some code I wrote in Basic a long time
ago, with some changes from stuff I cribbed from ccmatlab). If someone
knows of a python package that just "does this", I'd love to hear about
it. Either Az El, or X,Y,Z in ECI or ECF would do.
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to
https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
Tom Harris <celephicus@gmail.com>
On 4 July 2015 at 23:13, Jim Lux <jimlux@earthlink.net> wrote:
> I've got a project I'm working on to make a sophisticated sundial with
> moving mirrors. I've got a batch of Arduinos that move the mirrors to the
> appropriate places, given the current sun angle, etc.
>
> I've got a beaglebone that runs some python code to calculate sun angle
> based on time
>
> The beaglebone will have a GPS feeding it to get time.
>
> BUT now, I'd like to add a web interface, so that it can be manipulated by
> a mobile device using a browser.
>
> One way I can think of is to run some sort of limited web server. there
> are a couple that come with the beaglebone, including the python
> "simplehttpserver".
>
> But I'm sort of stuck on the interface between the webserver and the other
> code running.
>
> I've done this kind of thing where the one task goes out and updates files
> in the tree that's being served by the web server, and that works fine for
> "status display" kinds of things that don't update very quickly. It's also
> nicely partitioned.
>
> but I want to be able to change the behavior of the system (e.g. by having
> the server respond to a PUT or something)
>
> Is the best scheme to go in and modify the webserver code to look for
> specific URLs requested, and then fire off some custom code to do what I
> want?
>
> I'm not particularly interested in javascript, and would prefer python.
>
>
> Or are there libraries that make this more cookbook? (the little "getting
> started with beaglebone" book talks about flask)
>
> There's quite a few websites out there where someone has done some sort of
> "home automation", but they tend to be a bit light on the analysis of pros
> and cons of implementation architectures: "I built X using Y and Z and it
> sort of works".
>
>
> Actually, along a similar line.. my "solar position" code isn't very
> pretty (it's sort of replicating some code I wrote in Basic a long time
> ago, with some changes from stuff I cribbed from ccmatlab). If someone
> knows of a python package that just "does this", I'd love to hear about
> it. Either Az El, or X,Y,Z in ECI or ECF would do.
>
>
>
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
>
JL
Jim Lux
Tue, Jul 7, 2015 2:24 AM
On 7/6/15 3:19 PM, Tom Harris wrote:
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
The only hiccup with the cgi approach (and with "directly code the
action in the guts of the server" like with flask) is that the
subprocess that's spawned has to complete before control returns (e.g.
to serve stdout to the user). So if you want to fire off a task that
will run in parallel with the webserver's other stuff, you need to have
some sort of interprocess communication (e.g. a named pipe, socket,
file, MPI communicator, etc.). (or you do something like run "at" or
"batch", which is basically using a file as a interprocess
communication, and the at daemon watches the file)
On 7/6/15 3:19 PM, Tom Harris wrote:
> Since you want simple just use a CGI script written in your language of
> choice. Very easy technology to learn, Python has support libraries out of
> the box if you want. You have a webpge with carious simple controls on it
> like buttons etc, you click a special button that posts a request to a URL,
> the webserver runs a script that generates the response, the webserver
> serves it out, your browser displays it. Why bother with learning a
> framework? Messing about with mechanics is far more fun!
>
>
The only hiccup with the cgi approach (and with "directly code the
action in the guts of the server" like with flask) is that the
subprocess that's spawned has to complete before control returns (e.g.
to serve stdout to the user). So if you want to fire off a task that
will run in parallel with the webserver's other stuff, you need to have
some sort of interprocess communication (e.g. a named pipe, socket,
file, MPI communicator, etc.). (or you do something like run "at" or
"batch", which is basically using a file as a interprocess
communication, and the at daemon watches the file)
CA
Chris Albertson
Tue, Jul 7, 2015 2:28 AM
Yes cgi scripts take a few hours to learn and take only a small processor.
Drubbing a dims and all is overkill and will not perform well on the BBB.
On Monday, July 6, 2015, Tom Harris celephicus@gmail.com wrote:
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
Tom Harris <celephicus@gmail.com javascript:;>
On 4 July 2015 at 23:13, Jim Lux <jimlux@earthlink.net javascript:;>
wrote:
I've got a project I'm working on to make a sophisticated sundial with
moving mirrors. I've got a batch of Arduinos that move the mirrors to
appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun angle
based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be manipulated
a mobile device using a browser.
One way I can think of is to run some sort of limited web server. there
are a couple that come with the beaglebone, including the python
"simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the
code running.
I've done this kind of thing where the one task goes out and updates
in the tree that's being served by the web server, and that works fine
"status display" kinds of things that don't update very quickly. It's
nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by
the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for
specific URLs requested, and then fire off some custom code to do what I
want?
I'm not particularly interested in javascript, and would prefer python.
Or are there libraries that make this more cookbook? (the little "getting
started with beaglebone" book talks about flask)
There's quite a few websites out there where someone has done some sort
"home automation", but they tend to be a bit light on the analysis of
and cons of implementation architectures: "I built X using Y and Z and it
sort of works".
Actually, along a similar line.. my "solar position" code isn't very
pretty (it's sort of replicating some code I wrote in Basic a long time
ago, with some changes from stuff I cribbed from ccmatlab). If someone
knows of a python package that just "does this", I'd love to hear about
it. Either Az El, or X,Y,Z in ECI or ECF would do.
time-nuts mailing list -- time-nuts@febo.com javascript:;
To unsubscribe, go to
https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
--
Chris Albertson
Redondo Beach, California
Yes cgi scripts take a few hours to learn and take only a small processor.
Drubbing a dims and all is overkill and will not perform well on the BBB.
On Monday, July 6, 2015, Tom Harris <celephicus@gmail.com> wrote:
> Since you want simple just use a CGI script written in your language of
> choice. Very easy technology to learn, Python has support libraries out of
> the box if you want. You have a webpge with carious simple controls on it
> like buttons etc, you click a special button that posts a request to a URL,
> the webserver runs a script that generates the response, the webserver
> serves it out, your browser displays it. Why bother with learning a
> framework? Messing about with mechanics is far more fun!
>
>
> Tom Harris <celephicus@gmail.com <javascript:;>>
>
> On 4 July 2015 at 23:13, Jim Lux <jimlux@earthlink.net <javascript:;>>
> wrote:
>
> > I've got a project I'm working on to make a sophisticated sundial with
> > moving mirrors. I've got a batch of Arduinos that move the mirrors to
> the
> > appropriate places, given the current sun angle, etc.
> >
> > I've got a beaglebone that runs some python code to calculate sun angle
> > based on time
> >
> > The beaglebone will have a GPS feeding it to get time.
> >
> > BUT now, I'd like to add a web interface, so that it can be manipulated
> by
> > a mobile device using a browser.
> >
> > One way I can think of is to run some sort of limited web server. there
> > are a couple that come with the beaglebone, including the python
> > "simplehttpserver".
> >
> > But I'm sort of stuck on the interface between the webserver and the
> other
> > code running.
> >
> > I've done this kind of thing where the one task goes out and updates
> files
> > in the tree that's being served by the web server, and that works fine
> for
> > "status display" kinds of things that don't update very quickly. It's
> also
> > nicely partitioned.
> >
> > but I want to be able to change the behavior of the system (e.g. by
> having
> > the server respond to a PUT or something)
> >
> > Is the best scheme to go in and modify the webserver code to look for
> > specific URLs requested, and then fire off some custom code to do what I
> > want?
> >
> > I'm not particularly interested in javascript, and would prefer python.
> >
> >
> > Or are there libraries that make this more cookbook? (the little "getting
> > started with beaglebone" book talks about flask)
> >
> > There's quite a few websites out there where someone has done some sort
> of
> > "home automation", but they tend to be a bit light on the analysis of
> pros
> > and cons of implementation architectures: "I built X using Y and Z and it
> > sort of works".
> >
> >
> > Actually, along a similar line.. my "solar position" code isn't very
> > pretty (it's sort of replicating some code I wrote in Basic a long time
> > ago, with some changes from stuff I cribbed from ccmatlab). If someone
> > knows of a python package that just "does this", I'd love to hear about
> > it. Either Az El, or X,Y,Z in ECI or ECF would do.
> >
> >
> >
> > _______________________________________________
> > time-nuts mailing list -- time-nuts@febo.com <javascript:;>
> > To unsubscribe, go to
> > https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> > and follow the instructions there.
> >
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com <javascript:;>
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
>
--
Chris Albertson
Redondo Beach, California
BC
Bob Camp
Tue, Jul 7, 2015 11:13 AM
Hi
Having done this on very small machines with cgi before, the lag has never been
an issue. Yes, the things I do are “tweaks” to variables, or data requests. I do not try
to spawn a piece of code to compute PI to 800 places and wait for the result.
Bob
On Jul 6, 2015, at 10:24 PM, Jim Lux jimlux@earthlink.net wrote:
On 7/6/15 3:19 PM, Tom Harris wrote:
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
The only hiccup with the cgi approach (and with "directly code the action in the guts of the server" like with flask) is that the subprocess that's spawned has to complete before control returns (e.g. to serve stdout to the user). So if you want to fire off a task that will run in parallel with the webserver's other stuff, you need to have some sort of interprocess communication (e.g. a named pipe, socket, file, MPI communicator, etc.). (or you do something like run "at" or "batch", which is basically using a file as a interprocess communication, and the at daemon watches the file)
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
Hi
Having done this on *very* small machines with cgi before, the lag has never been
an issue. Yes, the things I do are “tweaks” to variables, or data requests. I do not try
to spawn a piece of code to compute PI to 800 places and wait for the result.
Bob
> On Jul 6, 2015, at 10:24 PM, Jim Lux <jimlux@earthlink.net> wrote:
>
> On 7/6/15 3:19 PM, Tom Harris wrote:
>> Since you want simple just use a CGI script written in your language of
>> choice. Very easy technology to learn, Python has support libraries out of
>> the box if you want. You have a webpge with carious simple controls on it
>> like buttons etc, you click a special button that posts a request to a URL,
>> the webserver runs a script that generates the response, the webserver
>> serves it out, your browser displays it. Why bother with learning a
>> framework? Messing about with mechanics is far more fun!
>>
>>
>
>
>
> The only hiccup with the cgi approach (and with "directly code the action in the guts of the server" like with flask) is that the subprocess that's spawned has to complete before control returns (e.g. to serve stdout to the user). So if you want to fire off a task that will run in parallel with the webserver's other stuff, you need to have some sort of interprocess communication (e.g. a named pipe, socket, file, MPI communicator, etc.). (or you do something like run "at" or "batch", which is basically using a file as a interprocess communication, and the at daemon watches the file)
>
>
>
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
JL
John Laur
Tue, Jul 7, 2015 8:34 PM
A small task queue or message queue would serve the purpose of tying the
webserver to the other external tasks: 1) Web server queues job; 2) polls
via ajax for status or they could run syncronously. Python is not my forte
but there are a number that look like they integrate very well with python.
A couple that look like they might be suitable from a quick google are huey
or celery.
John
On Tue, Jul 7, 2015 at 6:13 AM, Bob Camp kb8tq@n1k.org wrote:
Hi
Having done this on very small machines with cgi before, the lag has
never been
an issue. Yes, the things I do are “tweaks” to variables, or data
requests. I do not try
to spawn a piece of code to compute PI to 800 places and wait for the
result.
Bob
On Jul 6, 2015, at 10:24 PM, Jim Lux jimlux@earthlink.net wrote:
On 7/6/15 3:19 PM, Tom Harris wrote:
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out
the box if you want. You have a webpge with carious simple controls on
like buttons etc, you click a special button that posts a request to a
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
The only hiccup with the cgi approach (and with "directly code the
action in the guts of the server" like with flask) is that the subprocess
that's spawned has to complete before control returns (e.g. to serve stdout
to the user). So if you want to fire off a task that will run in parallel
with the webserver's other stuff, you need to have some sort of
interprocess communication (e.g. a named pipe, socket, file, MPI
communicator, etc.). (or you do something like run "at" or "batch", which
is basically using a file as a interprocess communication, and the at
daemon watches the file)
and follow the instructions there.
A small task queue or message queue would serve the purpose of tying the
webserver to the other external tasks: 1) Web server queues job; 2) polls
via ajax for status or they could run syncronously. Python is not my forte
but there are a number that look like they integrate very well with python.
A couple that look like they might be suitable from a quick google are huey
or celery.
John
On Tue, Jul 7, 2015 at 6:13 AM, Bob Camp <kb8tq@n1k.org> wrote:
> Hi
>
> Having done this on *very* small machines with cgi before, the lag has
> never been
> an issue. Yes, the things I do are “tweaks” to variables, or data
> requests. I do not try
> to spawn a piece of code to compute PI to 800 places and wait for the
> result.
>
> Bob
>
> > On Jul 6, 2015, at 10:24 PM, Jim Lux <jimlux@earthlink.net> wrote:
> >
> > On 7/6/15 3:19 PM, Tom Harris wrote:
> >> Since you want simple just use a CGI script written in your language of
> >> choice. Very easy technology to learn, Python has support libraries out
> of
> >> the box if you want. You have a webpge with carious simple controls on
> it
> >> like buttons etc, you click a special button that posts a request to a
> URL,
> >> the webserver runs a script that generates the response, the webserver
> >> serves it out, your browser displays it. Why bother with learning a
> >> framework? Messing about with mechanics is far more fun!
> >>
> >>
> >
> >
> >
> > The only hiccup with the cgi approach (and with "directly code the
> action in the guts of the server" like with flask) is that the subprocess
> that's spawned has to complete before control returns (e.g. to serve stdout
> to the user). So if you want to fire off a task that will run in parallel
> with the webserver's other stuff, you need to have some sort of
> interprocess communication (e.g. a named pipe, socket, file, MPI
> communicator, etc.). (or you do something like run "at" or "batch", which
> is basically using a file as a interprocess communication, and the at
> daemon watches the file)
> >
> >
> >
> > _______________________________________________
> > time-nuts mailing list -- time-nuts@febo.com
> > To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> > and follow the instructions there.
>
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
>
CA
Chris Albertson
Wed, Jul 8, 2015 4:03 AM
The other complication with simple CGI BIN scripts is if you have
multiple clients eating using their own browser. You have to manage
cookies or track IP addresses. Or for a simple home server, just let
thing fail if a second client starts making changes
On Mon, Jul 6, 2015 at 7:24 PM, Jim Lux jimlux@earthlink.net wrote:
On 7/6/15 3:19 PM, Tom Harris wrote:
Since you want simple just use a CGI script written in your language of
choice. Very easy technology to learn, Python has support libraries out of
the box if you want. You have a webpge with carious simple controls on it
like buttons etc, you click a special button that posts a request to a
URL,
the webserver runs a script that generates the response, the webserver
serves it out, your browser displays it. Why bother with learning a
framework? Messing about with mechanics is far more fun!
The only hiccup with the cgi approach (and with "directly code the action in
the guts of the server" like with flask) is that the subprocess that's
spawned has to complete before control returns (e.g. to serve stdout to the
user). So if you want to fire off a task that will run in parallel with the
webserver's other stuff, you need to have some sort of interprocess
communication (e.g. a named pipe, socket, file, MPI communicator, etc.).
(or you do something like run "at" or "batch", which is basically using a
file as a interprocess communication, and the at daemon watches the file)
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to
https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
--
Chris Albertson
Redondo Beach, California
The other complication with simple CGI BIN scripts is if you have
multiple clients eating using their own browser. You have to manage
cookies or track IP addresses. Or for a simple home server, just let
thing fail if a second client starts making changes
On Mon, Jul 6, 2015 at 7:24 PM, Jim Lux <jimlux@earthlink.net> wrote:
> On 7/6/15 3:19 PM, Tom Harris wrote:
>>
>> Since you want simple just use a CGI script written in your language of
>> choice. Very easy technology to learn, Python has support libraries out of
>> the box if you want. You have a webpge with carious simple controls on it
>> like buttons etc, you click a special button that posts a request to a
>> URL,
>> the webserver runs a script that generates the response, the webserver
>> serves it out, your browser displays it. Why bother with learning a
>> framework? Messing about with mechanics is far more fun!
>>
>>
>
>
>
> The only hiccup with the cgi approach (and with "directly code the action in
> the guts of the server" like with flask) is that the subprocess that's
> spawned has to complete before control returns (e.g. to serve stdout to the
> user). So if you want to fire off a task that will run in parallel with the
> webserver's other stuff, you need to have some sort of interprocess
> communication (e.g. a named pipe, socket, file, MPI communicator, etc.).
> (or you do something like run "at" or "batch", which is basically using a
> file as a interprocess communication, and the at daemon watches the file)
>
>
>
>
> _______________________________________________
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
--
Chris Albertson
Redondo Beach, California
BI
Brian Inglis
Wed, Jul 8, 2015 4:59 AM
On 2015-07-04 07:13, Jim Lux wrote:
I've got a project I'm working on to make a sophisticated sundial with moving mirrors. I've got a batch of Arduinos that move the mirrors to the appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun angle based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be manipulated by a mobile device using a browser.
One way I can think of is to run some sort of limited web server. there are a couple that come with the beaglebone, including the python "simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the other code running.
I've done this kind of thing where the one task goes out and updates files in the tree that's being served by the web server, and that works fine for "status display" kinds of things that don't update very quickly. It's also nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by having the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for specific URLs requested, and then fire off some custom code to do what I want?
May want to start with a control web page with an HTML FORM element and embedded input elements - easy even if you have not done much form design and entry implementation.
Submit target can be any URL designating a Python CGI script, which generates at least a Content-type header and HTML on stdout returned to the browser.
HTML output normally includes a copy of the original FORM (with values passed selected for editing) as well as HTML output and maybe inline or linked graphics.
You only need a web server that supports the CGI interface, with some way to configure it and say where the scripts are.
See Python cgi, html, http module docs to DIY.
--
Take care. Thanks, Brian Inglis
On 2015-07-04 07:13, Jim Lux wrote:
> I've got a project I'm working on to make a sophisticated sundial with moving mirrors. I've got a batch of Arduinos that move the mirrors to the appropriate places, given the current sun angle, etc.
> I've got a beaglebone that runs some python code to calculate sun angle based on time
> The beaglebone will have a GPS feeding it to get time.
> BUT now, I'd like to add a web interface, so that it can be manipulated by a mobile device using a browser.
> One way I can think of is to run some sort of limited web server. there are a couple that come with the beaglebone, including the python "simplehttpserver".
> But I'm sort of stuck on the interface between the webserver and the other code running.
> I've done this kind of thing where the one task goes out and updates files in the tree that's being served by the web server, and that works fine for "status display" kinds of things that don't update very quickly. It's also nicely partitioned.
> but I want to be able to change the behavior of the system (e.g. by having the server respond to a PUT or something)
> Is the best scheme to go in and modify the webserver code to look for specific URLs requested, and then fire off some custom code to do what I want?
May want to start with a control web page with an HTML FORM element and embedded input elements - easy even if you have not done much form design and entry implementation.
Submit target can be any URL designating a Python CGI script, which generates at least a Content-type header and HTML on stdout returned to the browser.
HTML output normally includes a copy of the original FORM (with values passed selected for editing) as well as HTML output and maybe inline or linked graphics.
You only need a web server that supports the CGI interface, with some way to configure it and say where the scripts are.
See Python cgi, html, http module docs to DIY.
--
Take care. Thanks, Brian Inglis
JL
Jim Lux
Wed, Jul 8, 2015 12:55 PM
On 7/7/15 9:59 PM, Brian Inglis wrote:
On 2015-07-04 07:13, Jim Lux wrote:
I've got a project I'm working on to make a sophisticated sundial with
moving mirrors. I've got a batch of Arduinos that move the mirrors to
the appropriate places, given the current sun angle, etc.
I've got a beaglebone that runs some python code to calculate sun
angle based on time
The beaglebone will have a GPS feeding it to get time.
BUT now, I'd like to add a web interface, so that it can be
manipulated by a mobile device using a browser.
One way I can think of is to run some sort of limited web server.
there are a couple that come with the beaglebone, including the python
"simplehttpserver".
But I'm sort of stuck on the interface between the webserver and the
other code running.
I've done this kind of thing where the one task goes out and updates
files in the tree that's being served by the web server, and that
works fine for "status display" kinds of things that don't update very
quickly. It's also nicely partitioned.
but I want to be able to change the behavior of the system (e.g. by
having the server respond to a PUT or something)
Is the best scheme to go in and modify the webserver code to look for
specific URLs requested, and then fire off some custom code to do what
I want?
May want to start with a control web page with an HTML FORM element and
embedded input elements - easy even if you have not done much form
design and entry implementation.
Submit target can be any URL designating a Python CGI script, which
generates at least a Content-type header and HTML on stdout returned to
the browser.
HTML output normally includes a copy of the original FORM (with values
passed selected for editing) as well as HTML output and maybe inline or
linked graphics.
You only need a web server that supports the CGI interface, with some
way to configure it and say where the scripts are.
See Python cgi, html, http module docs to DIY.
Yes, that seems to be the way..
The interesting thing is that the cgi needs to return reasonably fast,
or the user client will timeout, so it's not a good way to do something
that takes a long time. Great for "put parameters in a file" or "send
short command out IO device", not so great for "start long running
process that needs to continue after user has gone on to do other things.
So it comes down to lashing up some sort of interprocess communication,
whether it's a named pipe, a file that is shared between two processes,
IP sockets, etc.
On 7/7/15 9:59 PM, Brian Inglis wrote:
> On 2015-07-04 07:13, Jim Lux wrote:
>> I've got a project I'm working on to make a sophisticated sundial with
>> moving mirrors. I've got a batch of Arduinos that move the mirrors to
>> the appropriate places, given the current sun angle, etc.
>> I've got a beaglebone that runs some python code to calculate sun
>> angle based on time
>> The beaglebone will have a GPS feeding it to get time.
>> BUT now, I'd like to add a web interface, so that it can be
>> manipulated by a mobile device using a browser.
>> One way I can think of is to run some sort of limited web server.
>> there are a couple that come with the beaglebone, including the python
>> "simplehttpserver".
>> But I'm sort of stuck on the interface between the webserver and the
>> other code running.
>> I've done this kind of thing where the one task goes out and updates
>> files in the tree that's being served by the web server, and that
>> works fine for "status display" kinds of things that don't update very
>> quickly. It's also nicely partitioned.
>> but I want to be able to change the behavior of the system (e.g. by
>> having the server respond to a PUT or something)
>> Is the best scheme to go in and modify the webserver code to look for
>> specific URLs requested, and then fire off some custom code to do what
>> I want?
>
> May want to start with a control web page with an HTML FORM element and
> embedded input elements - easy even if you have not done much form
> design and entry implementation.
> Submit target can be any URL designating a Python CGI script, which
> generates at least a Content-type header and HTML on stdout returned to
> the browser.
> HTML output normally includes a copy of the original FORM (with values
> passed selected for editing) as well as HTML output and maybe inline or
> linked graphics.
> You only need a web server that supports the CGI interface, with some
> way to configure it and say where the scripts are.
> See Python cgi, html, http module docs to DIY.
>
Yes, that seems to be the way..
The interesting thing is that the cgi needs to return reasonably fast,
or the user client will timeout, so it's not a good way to do something
that takes a long time. Great for "put parameters in a file" or "send
short command out IO device", not so great for "start long running
process that needs to continue after user has gone on to do other things.
So it comes down to lashing up some sort of interprocess communication,
whether it's a named pipe, a file that is shared between two processes,
IP sockets, etc.