user8428217
user8428217

Reputation: 3

How to interact with Heroku from a js file

I have a python file named myfile uploaded on github and heroku app linked to that github repo.

Now when I run heroku run myfile.py on CLI of heroku it is working fine with the output as a string.

Also ,

So what I want is when user clicks a button in the page,

Anybody knows how to do this (in the script section of html ) ?

Upvotes: 0

Views: 100

Answers (1)

Damien MATHIEU
Damien MATHIEU

Reputation: 32627

The easiest way would be to change how myfile.py works, and to have it expose an API.

Using a tool such as gunicorn, you could expose an HTTP endpoint to your app. Your Javascript would then be able to make a call to that endpoint, and retrieve any response it sends.

See Getting started with Python on Heroku.

Upvotes: 1

Related Questions