google vision api

I am using google vision api to convert uploaded image into text and displaying it using flask. the website is giving 504 error loadbalancer. it is working in console but showing error on the webapp. please tell me how to fix it

is it this?


app = Flask(__name__)
photos = UploadSet('photos', IMAGES)


configure_uploads(app, photos)

@app.route('/index', methods=['GET', 'POST'])

def upload():

if request.method == 'POST' and 'photo' in request.files:



        vision_client = vision.Client()

        with, 'rb') as image_file:

            content =

            image = vision_client.image(

                content=content, )


        return render_template('x.html',t="text")
return render_template('index.html')

the site keeps on loading for 3-4 minutes and then shows error 504 load balancing. after uploading file keeps on loading and then shows error.

is it possible that that image.detect_full_text() function is taking a very long time to complete? try removing it and replacing it with a dummy value to check. then, if it is, try moving it out to an async worker:

it worked when i replaced it with some dummy value,when i ran image.detect_full_text() it takes a minute at most. is it possible that my app is not able to communicate to the web to access the api,if not how can i set up Asyncinwebapps

anything hosted on * will be accessible for free users. my guess is it's just taking too long. you can confirm by looking for the word "harakiri" in your server log (linked from the web tab)

if you see that, it's definitely timing out, and my best advice is to try an async task queue as suggested in that link.