Skip to content
Snippets Groups Projects
Commit 3bd5af08 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

DOC: enhance sss documentation

parent dcd5e48d
No related branches found
No related tags found
2 merge requests!117Release 0.12.2,!112DOC: enhance sss documentation
Pipeline #45617 passed
...@@ -241,6 +241,7 @@ Stand-alone documentation is built using Sphinx: `make doc` ...@@ -241,6 +241,7 @@ Stand-alone documentation is built using Sphinx: `make doc`
- recommonmark - recommonmark
- sphinx - sphinx
- sphinx-rtd-theme - sphinx-rtd-theme
- sphinx-a4doc
- sphinxcontrib-plantuml - sphinxcontrib-plantuml
- javasphinx :: `pip3 install --user javasphinx` - javasphinx :: `pip3 install --user javasphinx`
- Alternative, if javasphinx fails because python3-sphinx is too recent: - 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: ...@@ -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>` 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.
Please register or to comment