JimDu
Posts: 1
Joined: Fri Nov 22, 2013 1:29 pm

Posting data on Apache web site

Fri Nov 22, 2013 1:38 pm

Hello all,
I am new to Raspberry Pi and have an application I want to implement. I have USB devices that I want to plug in to the Pi that output data that I want the Pi to post dynamically to its internal hosted web site. I have installed Apache and constructed a simple web site but am stuck on how to port the USB data to it. Any help is appreciated.

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: Posting data on Apache web site

Sun Dec 01, 2013 11:00 am

Not really a Pi specific post is it?

There would be several ways to do this. You might consider a (bash) shell script that reads the data from the USB device and writes it to a file in a comma-separated format (for example). This script might be executed at system start-up, run periodically as a cron job or triggered to run when the USB device is plugged in to the Pi. In any case it is running independently of the Web server.

To view the data you write a cgi script to retrieve the data from the above file and process to some valid html. The cgi could be a shell script too, or written in Python or any other language, just follow the usual rules for that constitute a cgi program. You could use JQuery to provide timers to auto-refresh your page, display as a graph, all inserted into a portion of an otherwise static web page. All depends on your own requirements.

You could also have your cgi access the device directly, access its data, format and display as the web page is loaded.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Posting data on Apache web site

Sun Dec 01, 2013 11:47 am

What kind of USB devices are you talking about??

If you can extract data using the Pi console then the same is possible with Apache providing you don't require root access.

Richard S.

Return to “Beginners”