Call trame app with custom parameters

I am using Trame for 3d server-side rendering and still trying to understand how everything works. I used Trame cookie-cutter to create the project and being able to build and deploy it using the provided scripts.

I have figured out that when the service is called (I mean when you access the URL from the browser), the entry point for the trame service is main.py, and here a TrameApp object is created to build the UI.

My question is: is it possible to add more parameters to the “main()” method in main.py? I am used to using Django and FastAPI, so I expected to be able to do something like:
main(param1, param2) # handles calls to “http:///?param1=value1&param2=value2”
Or even better, being able to send these params in a GET request body.

Here is the project if it helps to understand my point: GitHub - Rebun13/exploring_trame: I am learning how Trame and the Trame server work
(“main.py” is in “trame_app/app/”)

You just need to add more command line argument using server.cli.

Then from there, in the docker bundle, url params can be passed and mapped to command line arguments by adjusting that YAML file. Just use things like ${param1} to get the mapping.

HTH

First of all, thank you for your answer.

I don’t understand a single thing about that. Where can I find an explanation on how this “apps.yml” file works? I can’t find any documentation or tutorial about it.

After creating the project, my apps.yml file looks like this:

trame: # Default app under /index.html
  app: trame-app
trame-app: # /trame-app.html
  app: trame-app

I am guessing that this configures “something” to call the Vue trame-app when those URLs are called, but I don’t understand how I can add parameters to that. I have tried this:

trame: # Default app under /index.html
  app: trame-app
  cmd:
    - --param1
    - ${param1}
    - --param2
    - ${param2}
trame-app: # /trame-app.html
  app: trame-app
  cmd:
     - --param1
    - ${param1}
    - --param2
    - ${param2}

And also added the parameters to the trame server with:

server.cli.add_argument(
        "--param1", help="Parameter 1", dest="param1"
    )
    server.cli.add_argument(
        "--param2", help="Parameter 2", dest="param2"
    )

But it doesn’t work:

2024-04-18 08:08:05,037:ERROR:wslink.launcher:The command line failed
2024-04-18 08:08:05,037:ERROR:wslink.launcher:--param1 value1 --param2 value2

Also, the first link you put in your previous answer is broken.

Again, thank you for your help.

Adding to this question, is there a way to provide this parameters inside the body of the HTTP GET request instead of putting them in the URL itself?

Thanks I fixes the link… It was a paste from a wrong buffer on a project that was not yet public.

For the documentation, it is capture in the readme inside trame/docker. (Which seems to be missing some info.) But the script that process that file might be as easier to read.

For the args, the url is the only option when using the same html file (index.html). But you can create your own launcher and start a session ahead of connecting to the trame process. In other words, you have many options depending on your setup and how you rather have the initialization flow managed.