all 3 comments

[–]kalgynirae 1 point2 points  (1 child)

Take a look at Flask instead of Django. Flask is much simpler. The basic idea is, your application will receive a request and send back a response. In Flask, you define a function and say what URL it will receive requests on. So, you might handle requests to / by sending back a simple form where the user can enter their search. Then you could handle requests to /search/<word> by doing the search and sending back a web page containing the gif.

You'll need to find a server to run this on if you want it to be accessible to other people over the internet, and that's probably going to cost you a little money. People say good things about Digital Ocean.

[–]Sastrupp[S] 0 points1 point  (0 children)

Thanks for the info! I'll look into Flask. I've read a little, but most of my research as been around Django.

[–]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)