-1

I have written a Python script and wish to deploy it as a "tool" using Flask. The workflow is:

  1. The user inputs information to be used at runtime by the script.
  2. The user hits an execute button.
  3. The output of the script is made available to the user via an output string displayed on-site that they can copy-paste.

It's a relatively complex problem and I need help coming to an understanding of how this can be done using Flask. What steps are involved? What documentation is available? Are there code samples I can look at to see how this is done?

Aleksey Bilogur
  • 3,686
  • 3
  • 30
  • 57

1 Answers1

1

Try adding a form with an input field in your template:

<form action=end_point_for_your_fn method="POST">
    Input: <input type="text" name="input">
</form>

Access the input in the Flask backend via request.form:

@app.route('/end_point_for_your_fn', methods=["POST"])
def your_fn():
    data = request.form['input']
Celeo
  • 5,583
  • 8
  • 39
  • 41
Amitkumar Karnik
  • 912
  • 13
  • 23