[Python] My Flask app is locally working but not able to deploy globally

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have the Flask app with implementing Meta.AI. It is running successfully in my local. I am getting the proper response from the Chatbot. But when I deploy in Global Like Render, Vercel, Heroku, I do not get a reaction from chatbot. I am always getting internal server errors.

    Here is my code App.py:

    from flask import Flask, render_template, request, jsonify
    from meta_ai_api import MetaAI
    from flask_cors import CORS
    import logging
    from main import MetaAI
    import sys
    import os

    current_dir = os.path.dirname(os.path.abspath(__file__))
    src_dir = os.path.dirname(current_dir)
    sys.path.insert(0, src_dir)


    app = Flask(__name__)
    CORS(app, resources={r"/*": {"origins": "*"}})


    ai = MetaAI()

    logging.basicConfig(level=logging.DEBUG)


    # Serve the HTML file
    @app.route('/')
    def home():
    return render_template('index.html')

    # API endpoint
    @app.route('/endpoint', methods=['POST'])
    def handle_chatbot_request():
    message = request.json['message']
    response = ai.prompt(message)
    return jsonify({'response': response})


    if __name__ == '__main__':
    # app.run(debug=True)

    #if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)

    Continue reading...

Compartilhe esta Página