Pass js variable in html template to google script

I have a .gs file which create a html page:

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index');
}

doGet();
console.log(myvariable);

and in that index.html file I’ll create a variable in tag, which I’d like to pass to my .gs file, for further putting it in google spreadsheet.

<script>
  var myvariable = 10;
</script>

Is there any method that can carry out my need?

Thank you.