Thanks Colin, but you missed the topic a little ;)
There simply is no Apache ;)
I already do it a similar way and record stuff in RRDs and want to speed
it up without changing the Webserver..
Michael
On 19.03.2014 00:45, Colin Reese wrote:
> Databases are NOT useless! Besides all the data enforcement, I want to
> plot things and store logs and variables. This is a silly thing to say.
>
> If you are firmly against storing any data, for any reason, take the
> following boilerplate ajax call (in your web page):
>
> function showMeData(data) {
>
> console.log(data); // or do whatever else you want here
>
> }
>
> function myAjaxFunction(sensorname,callback){
> $.ajax({
> var callback=showMeData;
> url: "/wsgireadsensor",
> type: "post",
> datatype:"json",
> data: {'sensorname':sensorname},
> success: function(response){
> // Execute our callback function
> callback(response);
> }
> });
>
> myAjaxFunction('blurgety-bloog',showMeData)
>
>
> Put your rendering/processing in showMeData, and call myAjaxFunction whenever
> you want. It is non-blocking (or not, if you want).
>
> All you need is a wsgi script on your server called "wsgireadsensor":
>
>
> def application(environ, start_response):
> import cgi, json
> from mylib import readowserversensor
>
> post_env = environ.copy()
> post_env['QUERY_STRING'] = ''
> post = cgi.FieldStorage(
> fp=environ['wsgi.input'],
> environ=post_env,
> keep_blank_values=True
> )
>
> # Get the form data
> formname=post.getvalue('name')
> data={}
> d={}
> for k in post.keys():
> d[k] = post.getvalue(k)
>
> status = '200 OK'
>
> # Run stuff as requested
> if 'sensorname' in d :
> data['result']= readowserversensor(d['sensorname'])
> if data['result']:
> data['status']='success!'
> else:
> data['status']='fail!'
> else:
> data=['empty']
>
> output = json.dumps(data,indent=1)
> response_headers = [('Content-type', 'application/json')]
> start_response(status,response_headers)
> return [output]
>
> Enable mod_wsgi and pop "WSGIScriptAlias /wsgisreadsensor
> /mydirectoryforwsgiscripts" into your apache site configuration and you're
> done. The data is returned to your web page call as json.
>
>
> See here for details:
> http://www.cupidcontrols.com/2014/01/creating-a-responsive-user-interface-updating-browser-data-in-real-time-using-jquery-and-ajax/
>
>
> Colin
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers