Skip to content

@chadselph /webui.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
simpler solution
import threading
from wsgiref.simple_server import make_server
from mylongtask import progress_status, run_task
# simple wsgi app; could replace with one from flask with templates,
# url dispatching, etc.
def simple_app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [str(progress_status)]
class TaskThread(threading.Thread):
def run(self):
# instead of just running the task, you could pull tasks
# off using the stdlib Queue module, and add a Flask
# endpoint for adding tasks onto the Queue. Fancy.
run_task()
class WebThread(threading.Thread):
def run(self):
httpd = make_server('', 8000, simple_app)
print "Serving on port 8000..."
httpd.serve_forever()
w = WebThread()
t = TaskThread()
w.start()
t.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.