Add custom button to html template of ner manual.

I want to add a custom button to the html template of ner manual, that send a request to my flask api on click. Just need that button so I can kill the process , so prodigy server working on port stops.

Hi! Adding the button should be pretty straightforward – you could use blocks and an html block with a <button> and then add an action to it with JavaScript. See here for details and examples: https://prodi.gy/docs/custom-interfaces

Stopping the server is a bit tricker because you need to be able to communicate with your Python process from the app. One way would be to add another endpoint to the app.py included with Prodigy, make a request to that endpoint when the button is clicked and kill the server running on the given port, e.g. like this:

HI! Ines yes am doing the same for killing the server running . But the thing is by adding button with blocks it shows in task container, which becomes unavailable when there are no more tasks.
I need a button that after the tasks get over and all things are saved to dataset , on clicking that button sent a request to my api to kill server.

Ah, that's a good point! Maybe just add it in JavaScript then? Something like this:

const button = document.createElement('button')
button.style = 'position: absolute; top: 10px; right: 10px;'
button.textContent = "Stop server"
button.addEventListener('click', () => { console.log('Do something...') })
document.body.appendChild(button)

Oh okay thanks! it worked!

1 Like