Example #1
0
def index():
    results = {}
    if request.method == "POST":
        # get url that the user has entered
        url = request.form['url']

        if 'http://' not in url[:7]:
            url = 'http://' + url

        job = q.enqueue_call(func=count_and_save_words, args=(url,), result_ttl=5000)
        print ("http://localhost:5000/results/"+str(job.get_id()))
    return render_template('index.html', results=results)
Example #2
0
def get_counts():
    # get url
    data = json.loads(request.data.decode())
    url = data["url"]
    # form URL, id necessary
    if 'http://' not in url[:7]:
        url = 'http://' + url

    # start job
    job = q.enqueue_call(
        func=count_and_save_words, args=(url,), result_ttl=5000
    )

    # return created job id
    return job.get_id()