Posts

Showing posts with the label API

How to run a Python program over the internet?

Image
What am I trying to solve? I want to run a python program whenever I need and get some information out of it. The problem is, I want to call that through internet. And I want to show the content on a web page or some UI container. That's it. Let put this as a requirement.Problem: Display some information on my web page calculated by a python program. 
How do we do it on our local computer? We run our program as : python my_program.py .So may be I can do something like: www.mywebsite.com/my_program.py . Can we? No idea.

I expect to collect the response in some variable (no idea how can I create a variable in the first place on html) and then display the contents of this variable . Displaying a simple text on html is known , so that should be easy.


The program You must remember that we want some information from our program . It's a basic GET call where you just ask for some information from a server. You may or may not pass some inputs while doing this.

fromflaskimportFlaskfromflas…