• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

203
Vistas
request returning "Endpoint request timed out"

I have deployed a flask app on aws lambda using zappa now the app is running fine on all end points except my main one when i give post request on it it returns { "message": "Endpoint request timed out" }

really need a fix or idea how to over come this i need to call the analysis route, the deployed url is

https://2ixfyfcsik.execute-api.eu-west-2.amazonaws.com/dev

tried increasing my app timeout limit none avail it seems api gateway has 30 second time out so how to by pass that or not how to make my app return results in 30 seconds any help appreciated

from flask import Flask, redirect, url_for, request, jsonify
from flask_cors import CORS
import os,json
from hatesonar import Sonar
from profanityfilter import ProfanityFilter


app = Flask(__name__)
CORS(app)



@app.route('/',methods = ['GET'])
def index():
    return jsonify({"message": "Hello World!"})



@app.route('/test',methods = ['GET'])
def test():
    results=[]
    post="Every Day. Narrated by Patch."
    sonar = Sonar()
    offensiveLanguage = sonar.ping(text=post)
    for item in offensiveLanguage['classes']:
        if (item['class_name']=='hate_speech'):
            if(item['confidence']>=0.9):
                hatesonar_hatespeech=item['coinfidence']
            else:
                hatesonar_hatespeech=0
            results.append(hatesonar_hatespeech)
        else:
            pass
        if (item['class_name']=='offensive_language'):
            if(item['confidence']>=0.9):
                hatesonar_swearing=item['coinfidence']
            else:
                hatesonar_swearing=0
            results.append(hatesonar_swearing)
    return jsonify(results)




@app.route('/offensiveLanguage',methods = ['POST', 'GET'])
def login():
   if request.method == 'POST':
      user = request.form['nm']
      return redirect(url_for('success',name = user))
   else:
      sonar = Sonar()
      text = request.args.get('text')
      print("text", text)
      offensiveLanguage = sonar.ping(text=text)
      print("offensiveLanguage", offensiveLanguage)
      return jsonify(offensiveLanguage)


@app.route('/analysis',methods = ['GET','POST'])
def profanity():
    if request.method == 'POST':
        profanitycount=0
        data = request.get_json()
        posts=[]
        for item in data:
            if ('media' in item):
                for x in item['media']:
                    if(x['mediaType']=='post'):
                        if (x['content']):
                            posts.append(x['content'])
                        else:
                            pass
                    else:
                        pass
            else:
                pass
        flat_list = []
        for sublist in posts:
            for item in sublist:
                flat_list.append(item)          
        for post in flat_list:
            pf = ProfanityFilter()
            swearing = pf.is_profane(post)
            if(swearing=='true'):
                profanitycount = profanitycount + 1
            else:
                profanitycount = profanitycount
            sonar = Sonar()
            offensiveLanguage = sonar.ping(text=post)   
    print("profanity", profanitycount)
    return jsonify(profanitycount)


if __name__ == '__main__':
        app.run()



over 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

if your request is sync then try to increase memory in Basic Setting of lambda. It was worked for me (Your function is allocated CPU proportional to the memory configured).

over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda