Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
On 21.03.2014 19:49, Paul Alfille wrote: Applied. Thanks. Thanks Paul! While doing further tests (and writing a demo-page as promised with jQuery and jQGrid which is pretty cool ;)) I found another problem which creates invalid JSON (jsonlint.com, jQuery also bails out..): owhttpd_read.c: FS_dir(ShowDeviceJsonCallback, out, pn); Should *not* output a comma after the last property/value in directory after ] and before } My tries to fix it where dirty quirks, maybe FS_dir is aware if there where records before or anymore are to come if and the Content-type is ct_json(?) P.S.: - The problem with ct_json not getting selected on further requests (Cache?) and outputting HTML instead of an empty JSON-object on simply invalid paths isn't that important because owhttpd still returns a) a 404 b) isn't valid JSON - which both could be caught easily for error-handling on the client.. Though it should be kept in mind as it's not 100% clean.. But this boost Web-Apps by 1000% on low-end platforms, so I think getting these really minor troubles fixed is really worth the effort! Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Addition: I cannot imagine anyone is able to use the JSON-API with 9.2p2, we could also break it I think, comments welcome ;) Another workaround I found afterwards without CORS would be to include load a JS with a static callback-function from owhttpd withing the calling site/page; implemented something similar like favicon in owhttpd.. But I'm happy as it is now with the CORS-Header.. Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
The 404 html output was simply a bug -- now fixed in the CVS version (free-ing the bad commend-line string before searching for json to decide which error output to produce). The trailing comma shouldn't be hard to fix either. Paul On Mon, Mar 24, 2014 at 11:13 AM, Michael Markstaller m...@elabnet.de wrote: Addition: I cannot imagine anyone is able to use the JSON-API with 9.2p2, we could also break it I think, comments welcome ;) Another workaround I found afterwards without CORS would be to include load a JS with a static callback-function from owhttpd withing the calling site/page; implemented something similar like favicon in owhttpd.. But I'm happy as it is now with the CORS-Header.. Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
On 21.03.2014 02:05, Paul Alfille wrote: What's the error page that's being discussed? Can you outline a command sequence that triggers it so I can investigate? Thanks, Paul Whenever a non-existing path is selected, it looks like in owhttpd_handler.c ct_json / ct_text is disregarded and HTML-output instead.. Michael CVS Diff to add CORS-Header and valid JSON-output on values (both works!) and an empty JSON object on errors (doesn't work): Index: module/owhttpd/src/c/owhttpd_handler.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_handler.c,v retrieving revision 1.101 diff -r1.101 owhttpd_handler.c 344c344 fprintf(out, null); --- fprintf(out, { }); 351a352 HTTPfoot(out); 353d353 HTTPfoot(out); 366c366 fprintf(out, null); --- fprintf(out, { }); 373a374 HTTPfoot(out); 375d375 HTTPfoot(out); Index: module/owhttpd/src/c/owhttpd_present.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_present.c,v retrieving revision 1.17 diff -r1.17 owhttpd_present.c 45a46 fprintf(out, Access-Control-Allow-Origin: *\r\n); Index: module/owhttpd/src/c/owhttpd_read.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_read.c,v retrieving revision 1.52 diff -r1.52 owhttpd_read.c 630a631 fprintf(out, [ ); 631a633 fprintf(out, ] ); -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Applied. Thanks. On Fri, Mar 21, 2014 at 10:11 AM, Michael Markstaller m...@elabnet.de wrote: On 21.03.2014 02:05, Paul Alfille wrote: What's the error page that's being discussed? Can you outline a command sequence that triggers it so I can investigate? Thanks, Paul Whenever a non-existing path is selected, it looks like in owhttpd_handler.c ct_json / ct_text is disregarded and HTML-output instead.. Michael CVS Diff to add CORS-Header and valid JSON-output on values (both works!) and an empty JSON object on errors (doesn't work): Index: module/owhttpd/src/c/owhttpd_handler.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_handler.c,v retrieving revision 1.101 diff -r1.101 owhttpd_handler.c 344c344 fprintf(out, null); --- fprintf(out, { }); 351a352 HTTPfoot(out); 353d353 HTTPfoot(out); 366c366 fprintf(out, null); --- fprintf(out, { }); 373a374 HTTPfoot(out); 375d375 HTTPfoot(out); Index: module/owhttpd/src/c/owhttpd_present.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_present.c,v retrieving revision 1.17 diff -r1.17 owhttpd_present.c 45a46 fprintf(out, Access-Control-Allow-Origin: *\r\n); Index: module/owhttpd/src/c/owhttpd_read.c === RCS file: /cvsroot/owfs/owfs/module/owhttpd/src/c/owhttpd_read.c,v retrieving revision 1.52 diff -r1.52 owhttpd_read.c 630a631 fprintf(out, [ ); 631a633 fprintf(out, ] ); -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
- Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? - Error-output: { } or {error : ...} instead of null+partial HTML.. This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! FF, Chrome(Webkit), Safari(Webkit), Opera, Dolphin, ... are all fine Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
2014-03-20 13:45 GMT-03:00 Michael Markstaller m...@elabnet.de: - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? trivial? well hehe a bit more than trivial, check code, i just leave because there was a lot of for while etc that create the page, but if you have time, it's nice to change :) maybe {value:11.5} is ok, no problem here, i'm using /text only today because i have old versions of owfs running - Error-output: { } or {error : ...} instead of null+partial HTML.. {error:} - no i think just {} is ok, a empty object / empty array, i don't know if null work with json/jsonp This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. yes - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. ok Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! no problem, ie isn't a standard web browser, and i think it will never be, i think it only work with some internet banking websites FF, Chrome(Webkit), Safari(Webkit), Opera, Dolphin, ... are all fine that's the main point: safari (apple), chrome (any computer or cellphone), firefox (the main web browser at companies) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
On 20.03.2014 18:11, Roberto Spadim wrote: 2014-03-20 13:45 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de: - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? trivial? well hehe a bit more than trivial, check code, i just leave because there was a lot of for while etc that create the page, but if you have time, it's nice to change :) maybe {value:11.5} is ok, no problem here, i'm using /text only today because i have old versions of owfs running This one is really easy! Just add the brackets.. I'll send a patch.. - Error-output: { } or {error : ...} instead of null+partial HTML.. {error:} - no i think just {} is ok, a empty object / empty array, i don't know if null work with json/jsonp This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. yes I have no idea, why, we end up in another source-path on the second false request, crying for help from Paul.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. ok Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! no problem, ie isn't a standard web browser, and i think it will never be, i think it only work with some internet banking websites We agree on this point ;) I'm fed up to implement the #40. workaround for IE and even native IE-Users give me support on this ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
nice :) the error page i don't remember what i done and how it work, must check with paul :/ 2014-03-20 16:00 GMT-03:00 Michael Markstaller m...@elabnet.de: On 20.03.2014 18:11, Roberto Spadim wrote: 2014-03-20 13:45 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de: - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? trivial? well hehe a bit more than trivial, check code, i just leave because there was a lot of for while etc that create the page, but if you have time, it's nice to change :) maybe {value:11.5} is ok, no problem here, i'm using /text only today because i have old versions of owfs running This one is really easy! Just add the brackets.. I'll send a patch.. - Error-output: { } or {error : ...} instead of null+partial HTML.. {error:} - no i think just {} is ok, a empty object / empty array, i don't know if null work with json/jsonp This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. yes I have no idea, why, we end up in another source-path on the second false request, crying for help from Paul.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. ok Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! no problem, ie isn't a standard web browser, and i think it will never be, i think it only work with some internet banking websites We agree on this point ;) I'm fed up to implement the #40. workaround for IE and even native IE-Users give me support on this ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
What's the error page that's being discussed? Can you outline a command sequence that triggers it so I can investigate? Thanks, Paul On Thu, Mar 20, 2014 at 6:35 PM, Roberto Spadim robe...@spadim.com.brwrote: nice :) the error page i don't remember what i done and how it work, must check with paul :/ 2014-03-20 16:00 GMT-03:00 Michael Markstaller m...@elabnet.de: On 20.03.2014 18:11, Roberto Spadim wrote: 2014-03-20 13:45 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de: - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? trivial? well hehe a bit more than trivial, check code, i just leave because there was a lot of for while etc that create the page, but if you have time, it's nice to change :) maybe {value:11.5} is ok, no problem here, i'm using /text only today because i have old versions of owfs running This one is really easy! Just add the brackets.. I'll send a patch.. - Error-output: { } or {error : ...} instead of null+partial HTML.. {error:} - no i think just {} is ok, a empty object / empty array, i don't know if null work with json/jsonp This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. yes I have no idea, why, we end up in another source-path on the second false request, crying for help from Paul.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. ok Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! no problem, ie isn't a standard web browser, and i think it will never be, i think it only work with some internet banking websites We agree on this point ;) I'm fed up to implement the #40. workaround for IE and even native IE-Users give me support on this ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
for example when you request a /asdfasdf/wj234ksdsfsdf at owhttp, the html error page is returned (i don't remember i'm not with source here, but i htink that's the error page) 2014-03-20 22:05 GMT-03:00 Paul Alfille paul.alfi...@gmail.com: What's the error page that's being discussed? Can you outline a command sequence that triggers it so I can investigate? Thanks, Paul On Thu, Mar 20, 2014 at 6:35 PM, Roberto Spadim robe...@spadim.com.brwrote: nice :) the error page i don't remember what i done and how it work, must check with paul :/ 2014-03-20 16:00 GMT-03:00 Michael Markstaller m...@elabnet.de: On 20.03.2014 18:11, Roberto Spadim wrote: 2014-03-20 13:45 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de: - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 I'd opt for [ 11.5 ] (unnamed array) for single values.. The change is really trivial, just add [] - any other opinions? trivial? well hehe a bit more than trivial, check code, i just leave because there was a lot of for while etc that create the page, but if you have time, it's nice to change :) maybe {value:11.5} is ok, no problem here, i'm using /text only today because i have old versions of owfs running This one is really easy! Just add the brackets.. I'll send a patch.. - Error-output: { } or {error : ...} instead of null+partial HTML.. {error:} - no i think just {} is ok, a empty object / empty array, i don't know if null work with json/jsonp This isn't trivial, on the first request I get what I expect, on the second++ a full HTML-answer? This would be really important for a useful error-handling in Ajax-clients.. yes I have no idea, why, we end up in another source-path on the second false request, crying for help from Paul.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. ok Overall: this works really great! 100x faster/less resource-usage than anything else which might also be a big benefit for any visualisation of owfs-data.. There is only one drawback: no IE below v10! no problem, ie isn't a standard web browser, and i think it will never be, i think it only work with some internet banking websites We agree on this point ;) I'm fed up to implement the #40. workaround for IE and even native IE-Users give me support on this ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
On 19.03.2014 00:44, Roberto Spadim wrote: something like this? |//JSON - instead of: {name:stackoverflow,id:5} //JSONP - return : func({name:stackoverflow,id:5});| Yes, exactly. I think a static callback-function like owhttp_callback({data ..}); would do the job.. While playing around with json-output in owhttpd I also found some oddities: - Single values (like /json/28.xxx/temperature) returns invalid JSON without curly brackets around {} the data - on Error/Not found etc. HTML is returned instead of JSON (also true for text. Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Hummm well all you need is owhttp.c file all json things are there add a new jsonp directory and start a nde patch :) Em quarta-feira, 19 de março de 2014, Michael Markstaller m...@elabnet.de escreveu: On 19.03.2014 00:44, Roberto Spadim wrote: something like this? |//JSON - instead of: {name:stackoverflow,id:5} //JSONP - return : func({name:stackoverflow,id:5});| Yes, exactly. I think a static callback-function like owhttp_callback({data ..}); would do the job.. While playing around with json-output in owhttpd I also found some oddities: - Single values (like /json/28.xxx/temperature) returns invalid JSON without curly brackets around {} the data - on Error/Not found etc. HTML is returned instead of JSON (also true for text. Michael -- 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 Owfs-developers@lists.sourceforge.net javascript:; https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
i don't know if we have the patch of json, maybe that's a nice start point for you owhttp is very easy to understand :) 2014-03-19 12:44 GMT-03:00 Paul Alfille paul.alfi...@gmail.com: Send a patch. We'll include it. On Wed, Mar 19, 2014 at 9:44 AM, Roberto Spadim robe...@spadim.com.brwrote: Hummm well all you need is owhttp.c file all json things are there add a new jsonp directory and start a nde patch :) Em quarta-feira, 19 de março de 2014, Michael Markstaller m...@elabnet.de escreveu: On 19.03.2014 00:44, Roberto Spadim wrote: something like this? |//JSON - instead of: {name:stackoverflow,id:5} //JSONP - return : func({name:stackoverflow,id:5});| Yes, exactly. I think a static callback-function like owhttp_callback({data ..}); would do the job.. While playing around with json-output in owhttpd I also found some oddities: - Single values (like /json/28.xxx/temperature) returns invalid JSON without curly brackets around {} the data - on Error/Not found etc. HTML is returned instead of JSON (also true for text. Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Send a patch. We'll include it. On Wed, Mar 19, 2014 at 9:44 AM, Roberto Spadim robe...@spadim.com.brwrote: Hummm well all you need is owhttp.c file all json things are there add a new jsonp directory and start a nde patch :) Em quarta-feira, 19 de março de 2014, Michael Markstaller m...@elabnet.de escreveu: On 19.03.2014 00:44, Roberto Spadim wrote: something like this? |//JSON - instead of: {name:stackoverflow,id:5} //JSONP - return : func({name:stackoverflow,id:5});| Yes, exactly. I think a static callback-function like owhttp_callback({data ..}); would do the job.. While playing around with json-output in owhttpd I also found some oddities: - Single values (like /json/28.xxx/temperature) returns invalid JSON without curly brackets around {} the data - on Error/Not found etc. HTML is returned instead of JSON (also true for text. Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Ok, I'm struggling mainly with the JSONP/Client-side, owhttpd is easy to understand all fine.. (although adding commandline-parameters - see below might require some help) - Now first of all, I'd submit a patch to fix /json outputting valid JSON-Data. This would change the current behavior i.e.: single elements: { value : 11.5 } instead of 11.5 - Error-output: { } or {error : ...} instead of null+partial HTML.. - Add a HTTP-Header (Access-Control-Allow-Origin: *) to enable CORS for JSON. This could be a security-risk, but on an already open owhttpd I don't see any further risk in this case.. If needed, we could also add a commandline-parameter(?) but anybody with access to owhttpd can read any value anyway without Ajax - so why care.. With CORS working (which is just about this HTTP-Header on server-side!) JSONP isn't needed anymore (besides IE10 which I really don't care about) After, I'll write a summary how to use it; it's very simple but nearly any doc on the net about JSONP/CORS is only just confusing ;) Do you prefer the CVS-Diff or a patch-file? Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
[Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Hi, did anybody already do something asking owhttp (JSON) from within another Site (same host, another port - which Same-Origin-Policy disallows)? The Basics are clear, CORS or JSONP, just don't want to re-invent the wheel ;) Michael P.S.: I'm just changing some old stuff and want to avoid having another Perl/CGI/.. in between to fetch with owget/OWNet values as asking owhttpd directly using XMLHttpRequest makes much more sense and much less overhead on small boxes IMHO. -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
i use text/ and parse everything with javascript that's a single text but you can use json/ too 2014-03-18 13:37 GMT-03:00 Michael Markstaller m...@elabnet.de: Hi, did anybody already do something asking owhttp (JSON) from within another Site (same host, another port - which Same-Origin-Policy disallows)? The Basics are clear, CORS or JSONP, just don't want to re-invent the wheel ;) Michael P.S.: I'm just changing some old stuff and want to avoid having another Perl/CGI/.. in between to fetch with owget/OWNet values as asking owhttpd directly using XMLHttpRequest makes much more sense and much less overhead on small boxes IMHO. -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
I puts it in a sqlite database using python and then grab it from there using jQuery/js On Tue, Mar 18, 2014 at 9:51 AM, Roberto Spadim robe...@spadim.com.brwrote: i use text/ and parse everything with javascript that's a single text but you can use json/ too 2014-03-18 13:37 GMT-03:00 Michael Markstaller m...@elabnet.de: Hi, did anybody already do something asking owhttp (JSON) from within another Site (same host, another port - which Same-Origin-Policy disallows)? The Basics are clear, CORS or JSONP, just don't want to re-invent the wheel ;) Michael P.S.: I'm just changing some old stuff and want to avoid having another Perl/CGI/.. in between to fetch with owget/OWNet values as asking owhttpd directly using XMLHttpRequest makes much more sense and much less overhead on small boxes IMHO. -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
Thats exactly the overhead I want to avoid like owserver-owget/ownet-sql-CGI-Client Doing this with - let's say 50 sensors - every 10sec produces a bunch of useless load where the client only needs it once a week for 2h.. Michael On 18.03.2014 18:20, Colin Reese wrote: I puts it in a sqlite database using python and then grab it from there using jQuery/js -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
50/10 = 5 sensors/second, that's near 0bytes/second hehe i don't see a big overhead in this scenario, maybe with 100 users, but with more than 1000+ users, i prefer a sql server, not a sqlite database, with cache, etc etc... 2014-03-18 14:42 GMT-03:00 Michael Markstaller m...@elabnet.de: Thats exactly the overhead I want to avoid like owserver-owget/ownet-sql-CGI-Client Doing this with - let's say 50 sensors - every 10sec produces a bunch of useless load where the client only needs it once a week for 2h.. Michael On 18.03.2014 18:20, Colin Reese wrote: I puts it in a sqlite database using python and then grab it from there using jQuery/js -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
I'm not sure who this was directed to. Polling and data management: owserver--owpython--sqlite User interface: sqlite--wsgi/ajax--json--jQuery/js Wsgi is very fast. I have used cgi and it is quite slow in comparison. I'm not really sure the overhead you are speaking of, if you are comparing text to database queries. I have not run an apples to apples comparison on fetched flat text vs wsgi/sqlite of the same data, but I'd bet the difference is nothing to speak of. I used text files before I moved to databases, and there is just no comparison. With a text file, you must hard-code everything. This is the definition of inflexible and unscalable. Every time I wanted to add something, I had to rewrite at least one text handler, but generally multiple. Now, I can add an action to my wsgi script and pass options through json POST without changing anything that exists. I can add fields to a database without breaking old code. This is not even to mention reinforcing data relations and all the other 'beyond just a container' features of a well-designed database. Besides, do text files jump up and down for you like a python script? Do they return dictionaries that come through as json into the DOM? I've had quite enough text parsing for one lifetime, thank you. In terms of the configuration, load is determined by poll frequency. You control that through the database control parameters. Poll one every ten minutes, one every week. Only run the poll script once a year if you want. It's no different except it's easier to adjust with a database instead of text files. https://github.com/iinnovations/iicontrollibs/ weblibs will be published shortly at https://github.com/iinnovations/cupidweblib Colin On Tue, Mar 18, 2014 at 10:39 AM, Michael Markstaller m...@elabnet.de wrote: How do you access owhttpd (:3001) from another (web)site using AJAX or similar ? It's about CORS obviously not suitable for older Mickeysoft-browsers and owhttpd not JSONP (which could be added easily though..) As I'm due to roll-out a new owfs anyway, I don't care about changes/new versions here ;) Michael On 18.03.2014 17:51, Roberto Spadim wrote: i use text/ and parse everything with javascript that's a single text but you can use json/ too 2014-03-18 13:37 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de: Hi, did anybody already do something asking owhttp (JSON) from within another Site (same host, another port - which Same-Origin-Policy disallows)? The Basics are clear, CORS or JSONP, just don't want to re-invent the wheel ;) Michael P.S.: I'm just changing some old stuff and want to avoid having another Perl/CGI/.. in between to fetch with owget/OWNet values as asking owhttpd directly using XMLHttpRequest makes much more sense and much less overhead on small boxes IMHO. -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
It was directed at Roberto using owhttpd/text; I'll explain a little: I have a Webmin (Perl, Port :1) Interface which uses a Perl-CGI to get/refresh values via OWNet/Ajax. It works but it's dead slow and - depending on the refresh-interval and sensorcount - nearly kills the server. I cannot change the Webmin-Frontend for now or the involved miniser.pl shortly, so I'm looking for a way without using the same Server/Port to get values out of owfs(owserver). Could easily write a CGI in C on the same machine running lighttpd but there I have the same Same-Origin-Policy-problem, so I think using owhttpd directly is the leanest solution; Just wanted to know if there are other ways around, currently I think implementing JSONP (read the P!) for owhttpd might be the best option(?) Michael On 18.03.2014 20:34, Colin Reese wrote: I'm not sure who this was directed to. Polling and data management: owserver--owpython--sqlite User interface: sqlite--wsgi/ajax--json--jQuery/js Wsgi is very fast. I have used cgi and it is quite slow in comparison. I'm not really sure the overhead you are speaking of, if you are comparing text to database queries. I have not run an apples to apples comparison on fetched flat text vs wsgi/sqlite of the same data, but I'd bet the difference is nothing to speak of. I used text files before I moved to databases, and there is just no comparison. With a text file, you must hard-code everything. This is the definition of inflexible and unscalable. Every time I wanted to add something, I had to rewrite at least one text handler, but generally multiple. Now, I can add an action to my wsgi script and pass options through json POST without changing anything that exists. I can add fields to a database without breaking old code. This is not even to mention reinforcing data relations and all the other 'beyond just a container' features of a well-designed database. Besides, do text files jump up and down for you like a python script? Do they return dictionaries that come through as json into the DOM? I've had quite enough text parsing for one lifetime, thank you. In terms of the configuration, load is determined by poll frequency. You control that through the database control parameters. Poll one every ten minutes, one every week. Only run the poll script once a year if you want. It's no different except it's easier to adjust with a database instead of text files. https://github.com/iinnovations/iicontrollibs/ weblibs will be published shortly at https://github.com/iinnovations/cupidweblib Colin On Tue, Mar 18, 2014 at 10:39 AM, Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de wrote: How do you access owhttpd (:3001) from another (web)site using AJAX or similar ? It's about CORS obviously not suitable for older Mickeysoft-browsers and owhttpd not JSONP (which could be added easily though..) As I'm due to roll-out a new owfs anyway, I don't care about changes/new versions here ;) Michael On 18.03.2014 17:51, Roberto Spadim wrote: i use text/ and parse everything with javascript that's a single text but you can use json/ too 2014-03-18 13:37 GMT-03:00 Michael Markstaller m...@elabnet.de mailto:m...@elabnet.de mailto:m...@elabnet.de mailto:m...@elabnet.de: Hi, did anybody already do something asking owhttp (JSON) from within another Site (same host, another port - which Same-Origin-Policy disallows)? The Basics are clear, CORS or JSONP, just don't want to re-invent the wheel ;) Michael P.S.: I'm just changing some old stuff and want to avoid having another Perl/CGI/.. in between to fetch with owget/OWNet values as asking owhttpd directly using XMLHttpRequest makes much more sense and much less overhead on small boxes IMHO. -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
could you explain it better, for example, write a directory with /text, /json and /jsonp to see what change, and what should be implemented, it's easier to understand, since i don't understand the P part 2014-03-18 20:17 GMT-03:00 Michael Markstaller m...@elabnet.de: After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
something like this? //JSON - instead of:{name:stackoverflow,id:5}//JSONP - return : func({name:stackoverflow,id:5}); 2014-03-18 20:39 GMT-03:00 Roberto Spadim robe...@spadim.com.br: could you explain it better, for example, write a directory with /text, /json and /jsonp to see what change, and what should be implemented, it's easier to understand, since i don't understand the P part 2014-03-18 20:17 GMT-03:00 Michael Markstaller m...@elabnet.de: After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
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 On Tue, Mar 18, 2014 at 4:17 PM, Michael Markstaller m...@elabnet.de wrote: After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
In order for jsonp to work, you'd have to get httpd on a port that would make it through whatever gateway devices you plan on routing it through. You could probably do this on 88, although jsonp must have provision for this, which I don't know for sure. Colin On Tue, Mar 18, 2014 at 4:39 PM, Roberto Spadim robe...@spadim.com.brwrote: could you explain it better, for example, write a directory with /text, /json and /jsonp to see what change, and what should be implemented, it's easier to understand, since i don't understand the P part 2014-03-18 20:17 GMT-03:00 Michael Markstaller m...@elabnet.de: After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
Re: [Owfs-developers] owhttpd / JSONP / Cross-Origin Resource Sharing (CORS)
I also have to imagine this would raise security red flags wherever it goes. Colin On Tue, Mar 18, 2014 at 4:48 PM, Colin Reese colin.re...@gmail.com wrote: In order for jsonp to work, you'd have to get httpd on a port that would make it through whatever gateway devices you plan on routing it through. You could probably do this on 88, although jsonp must have provision for this, which I don't know for sure. Colin On Tue, Mar 18, 2014 at 4:39 PM, Roberto Spadim robe...@spadim.com.brwrote: could you explain it better, for example, write a directory with /text, /json and /jsonp to see what change, and what should be implemented, it's easier to understand, since i don't understand the P part 2014-03-18 20:17 GMT-03:00 Michael Markstaller m...@elabnet.de: After some hours of investigation, I think implementing JSONP (again, note the P!) in owhttpd looks like the best solution(?) This would IMHO also be useful for some other solutions maybe to avoid useless workarounds like writing DB's and then query the same.. I'm willing to try do it (though limited C know-how) like /json /text just /jsonp. Any thoughts still welcome, the question is still: how to get values from owfs/owserver directly without using crude workarounds like writing a DB first etc ;) Michael -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers -- 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 Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers