✓ Solved

How to use Post request in html button - linode instance

This might be beginner question but I need your support to guide me where to start.

I want to be able to use a button in html code to boot/reboot linode instance. This is used for lab at home and want to be able to do the actions from the page I delivered, not from the linode portal.

I reviewed the API example:

"
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X POST \
https://api.linode.com/v4/linode/instances/123/reboot
"

here my code in html:

"…….

<div class="btn-group">
<button class="btn btn-success btn-flat" type="button"> Boot VM </button>

……..
"

I'm not sure how can I use it in the html code to do the action.

should I create a json file in the same directory and call the function in html ? if so, how ?

I wrote a python code separately which do the same but I want to be able to embed it in the html code so when I click the button it takes action.

This is used for lab where I want to be able to control the instance status from the web page without logging to the portal.

FYI: the application backend is built with flask and front end with html.

</div>

2 Replies

✓ Best Answer

……

<div class="btn-group">
<button class="btn btn-success btn-flat" type="button"> Boot VM </button>
……

This just causes a button to be rendered on the page. The HTML above doesn't even tell the browser to send button clicks anywhere.

FYI: the application backend is built with flask and front end with html.

You need to attach some sort of action in your Flask app to handle an event provided by the button click.

See: https://stackoverflow.com/questions/46482475/how-handle-a-button-click-on-python-flask

-- sw

HTML isn't the right language to do this in because HTML is not a programming language. You will need to augment your page with something that allows for scripting and API calls; Python, JS, etc.

Additionally, Linode doesn't actually provide this kind of support. It might be better for you to ask in a forum where that kind of expertise is available, like Stack Exchange.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct