Forums

Issues with urllib on 2.7

I've created a few functions that will open a few urls and then use a regex to look for keywords. They work great in Bash but when I try to add them to my app they page won't load. Here are the two functions and return page:

def looper(sites):
    a = []
    for x in sites:
        a += [urllib.urlopen(x)]
    return a

def reader(var):
    b = []
    for x in var:
        b += [re.findall(r'Please', x.read())]
    return b

@app.route('/looper1')
def looper1():
    site = ['http://tlamanna42.pythonanywhere.com', 'http://tlamanna42.pythonanywhere.com']
    c = looper(site)
    d = reader(c)
    return d

I know the sites are whitelisted and again it works just fine in the console, but when I try to use it in the app itself it won't load.

You're making requests to your own web app and a Free account only gets one worker per web app, so it's blocking waiting for a worker to be available.

Would the $5 per month plan solve this issue?

Yes, but only for 1 access at a time.