Populate HTML template with data from a Database

Hi there,

I am looking for the best way to populate a HTML template (like a sport ranking) from a database.
Thinking out loud: what is the best way to update data in an HTML Template from a webservice?

  1. Use Javascript in the template itself;
  2. Push data to the Caspar CG and tell him to update the template with it;

First one is quite easy to do, but I think it is better to use the second approach, right? Then how can I do it?
Is there a way to say “Hey Caspar, change the field X in the template Y” keeping the template on air and triggerinng something like a transition while applying the chage.

Any ideas, exemple?
Thanks!!

First you will need JavaScript inside your template anyway. To make change data dynamically.

There is, it’s called UPDATE and you send the data with it. To make a transition on a update you need to write JavaScript code in your update handler. There are examples around here in the forum. Use the serach bar on the top right.

One possibility is to use node.js so that you can do database logic before sending your amcp commands off to casparcg server using something like https://github.com/SuperFlyTV/casparcg-connection. You could replace the database logic part with network calls if you wanted to go the webservice route.

Assuming that data is on DB on remote server you can do it pretty easy:

JS script in your template:

  • on update metod call sever-side script using AJAX
  • parse response
  • display data

serverside script:

  • get data from db
  • encode and return ie. json

remember about cros-origin read blocking :slight_smile: