title: Python Rest API calling python script before to get response for client
body: <p>I am new to python and I'm trying to implement a rest api in python using flask framework. The goal is when the api is called, I want to implement some logic that will execute a python script and return that output as the API response to the client.</p>
  
  <p>Here what I have for my simple rest service </p>
  
  <p>hello.py</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  
  @app.route("/tasks")
  def get_tasks():
    return "return json output"
  </code></pre>
  
  <p>python script that I would like to be called and executed
  mypythonscript.py</p>
  
  <pre><code>print("My first simple Python script!")
  </code></pre>
  
  <p>Ultimately, I'll get the script output whenever I call the rest API. Is this possible? any pointers or documentation/resources or examples of something similar would greatly help!  </p>