Introduce tooldaq.js -- a new API for the web server#40
Introduce tooldaq.js -- a new API for the web server#40brichards64 merged 6 commits intoToolDAQ:masterfrom
Conversation
|
in |
|
Done.
I have removed
Done. I used
I considered that. The problem is that we can check the return code only after psql has returned and closed its output stream, while we need to set the status code at the beginning of our output. That means that we need to capture psql output in a variable first, and it can be very large. Current implementation checks the first line of the stream and pipes the rest to the client. If the client decides that they don't want all of the data, they can close the stream and the query will stop midway. I think the way it works now is well enough. If you want it more robust, then in my opinion it's better to implement it in C++ rather than bash. I can do that when we have a problem with it.
Good point. I am thinking of abstracting plot functions to a class that would govern a plot on a div. It could provide methods for updating and modifying the plot. A similar class should probably be written for services. They can be moved out to separate modules. However, I must work now on other projects, so this will have to wait for a while. |
cfce98f to
74ca565
Compare
|
delete standalone 2 |
Make backgroundSD2 to produce a plain CSV table. Move Content-type to tablecontent5.cgi and change it from text/html to text/plain.
See docs/tooldaq.mkd for the documentation
Use `std::chrono` to set `msg_time`
Introduce
tooldaq.jswhich is intended to replacefunctions.jseventually. It should be able to do everything thatfunctions.jsdoes now, but with error handling and hopefully more concise interface. Seedocs/tooldaq.mkdfor the documentation.I may have overengineered the
makeTablefunction. Let me know what you think about it.New files and changes to old ones:
cgi-bin/command.cgiis used to send commands. It does the same thing assendcommand.cgi, but emits no HTML code, just the command reply as plain text, and also returns code 500 with an error message if something goes wrong.cgi-bin/db-query.cgiis used to talk to the database. It can return data in JSON or in CSV format, both of which can be handled intooldaq.js. CSV format should use less bandwidth, but sometimes JSON is more convenient. Hopefully it will replacesqlquery.cgi,sqlqueryjson.cgiandsqlquerystring.cgi.services.txtinhtml-Detectorandhtml-Standalone*which is a symlink to/tmp/table_file. That wayhttpddoesn't need to execute a CGI script to distribute the table. This should maketablecontent5.cgiobsolete.cgi-bin/backgroundSD2was changed to not emit Content-type header and HTML code. They are ignored anyway infunctions.js'sGetSDTable, so it doesn't break old code. Now the table file (services.txt) can be served as plain text.