У меня есть эта проблема в моем приложении Google App Engine. Когда я запускаю приложение с gcloud app browse
, на странице появляется следующее сообщение об ошибке:
'502 Bad Gateway nginx'
Я использую приложение Flask.
Вот код:
import os
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from uuid import uuid4
from flask import Flask, request, render_template, send_from_directory
import io
from google.cloud import vision
from google.cloud.vision import types
app = Flask(__name__)
app.config['UPLOADED_PHOTOS_DEST'] = os.getcwd()
photos = UploadSet('photos', IMAGES)
configure_uploads(app, photos)
patch_request_class(app)
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="json_key.txt"
vision_client = vision.ImageAnnotatorClient()
@app.route('/', methods=['GET', 'POST'])
def upload_file():
labels = ''
file_url1 = ''
filename = ''
file_url = ''
target = os.path.join(APP_ROOT, '/')
if request.method == 'POST' and 'photo' in request.files:
filename = photos.save(request.files['photo'])
file_url = photos.url(filename)
with io.open(filename, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
response = vision_client.label_detection(image=image)
labels = response.label_annotations
return render_template('index.html', thelabels=labels,image_name=file_url)
"""@app.route('/<filename>')
def send_image(filename):
#return render_template('index.html', filename=filename)
return send_from_directory("/", filename)"""
if __name__ == '__main__':
app.run()
Это файл app.yaml:
runtime: python37
И я не использую файл require.txt!?