Skip to content
Snippets Groups Projects
Commit c7960d14 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-sss-doc' into 'dev'

DOC: enhance sss documentation

See merge request !112
parents 8b17e785 3e94e795
No related branches found
No related tags found
2 merge requests!117Release 0.12.2,!112DOC: enhance sss documentation
Pipeline #46430 failed
......@@ -241,6 +241,7 @@ Stand-alone documentation is built using Sphinx: `make doc`
- recommonmark
- sphinx
- sphinx-rtd-theme
- sphinx-a4doc
- sphinxcontrib-plantuml
- javasphinx :: `pip3 install --user javasphinx`
- Alternative, if javasphinx fails because python3-sphinx is too recent:
......
sphinx-rtd-theme
sphinxcontrib-plantuml
javasphinx
sphinx-a4doc
......@@ -83,3 +83,44 @@ An invocation via a button in javascript could look like:
For more information see the :doc:`specification of the API <../specification/Server-side-scripting>`
Calling from the webui
---------------------
Refer to `webui documentation <https://docs.indiscale.com//caosdb-webui/extension/forms.html#calling-a-server-side-script>`_ to learn how to setup the webui side of this interaction.
The following example assumes that the form in the webui has only one filed
which is a file upload with the name ``csvfile``.
.. code-block:: python
import os
import linkahead as db
from caosadvancedtools.serverside import helper
from caosadvancedtools.serverside.logging import configure_server_side_logging
def main():
parser = helper.get_argument_parser()
args = parser.parse_args()
db.configure_connection(auth_token=args.auth_token)
# setup logging and reporting if serverside execution
userlog_public, htmluserlog_public, debuglog_public = configure_server_side_logging()
if not hasattr(args, "filename") or not args.filename:
raise RuntimeError("No file with form data provided!")
# Read the input from the form (form.json)
with open(args.filename) as form_json:
form_data = json.load(form_json)
# files are uploaded to this dicectory
upload_dir = os.path.dirname((args.filename))
# Read content of th uplaoded file
csv_file_path = os.path.join(upload_dir, form_data["csvfile"])
# Do something with the upload csv file...
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment