0

What is the simplest way for making a Python script run in a webserver and allow me to call it passing a parameter and grabbing the value that the script ends up with?

I am thinking that this is what is normally refered to as an API, but not sure how to implement this in the most simple way.

The application from which I would be calling this python script is ManyChat, through its feature "external requests" which allows me to use GET or POST parameters, but I don't know how I would turn my python script into a web queriable api.

https://support.manychat.com/support/solutions/articles/36000018457-dev-tools-external-request-and-dynamic-block-

I took a look online and found some articles about Python + Flask but it seems a solution for scenario where SQL database is involved in the operations. However my python script will NOT need to communicate with any SQL database so I am wondering if there is a simpler solution

3
  • 2
    I don't think flask needs SQL at all. It's one of the simplest frameworks there is. Commented Mar 17, 2019 at 12:02
  • thank you @NoSplitSherlock. Upon taking a second look, It seems I might have judged too soon Flask for the purpose of creating simple API. I'll take a closer look to it, unless somebody suggests an even simpler approach Commented Mar 17, 2019 at 12:10
  • 1
    Just Google for a flask api tutorial. I think most of them would almost word for word explain what you want to do. Commented Mar 17, 2019 at 12:19

1 Answer 1

1

Flow control could be as follows:

  • Flask app running on /api on your web server
  • Client app does requests.get('myserver.com/api?p1=v1&p2=v2')
  • Flask app handles request and runs function under @app.route('/api')
  • Client app receives response
Sign up to request clarification or add additional context in comments.

2 Comments

thanks. I've followed a tutorial and I have my first Flask api working after running the python file that holds all its code by manually typing in my localhost Terminal prompt "python3 app.py", and testing the GET requests with Insomnia. But how would I make this same app.py file be constantly running on my webserver? do I have to put app.py in a specific folder for it to be permanently running?
ok, disregard, I found the information that answers my question here: flask.pocoo.org/docs/1.0/deploying/#deployment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.