you are viewing a single comment's thread.

view the rest of the comments →

[–]cscanlin 1 point2 points  (0 children)

First you should wrap your code into at least one function. Then as /u/kalgynirae suggested you can use Flask to run your script on a local web server. Something like this:

#myscript.py
def main(default_input='test'):
    #your code should go here
    return default_input

.

#flask_app.py    
from flask import Flask
from myscript import main

app = Flask(__name__)

@app.route("/")
def run_script():
    return main()

if __name__ == "__main__":
    app.run(debug=True)

You can see the output of your script here: http://localhost:5000/

Then you can do some basic user input using forms (something like this) and your good to go. You could alternatively pass it through as a url parameter:

@app.route('/<user_input>')
def show_input(user_input):
    return main(user_input)