I can’t file a request for flask through the angular on apache

Asked

Viewed 162 times

0

[RESOLVED]

I managed to solve. I used Proxypass to redirect meudominio/api requests to localhost:8000, and changed the request url in my angular project to meudominio/api, and then it started working, I don’t know if it’s the best way since I don’t know much about apache.

[ORIGINAL QUESTION]

I am facing a problem to run an application on a Ubuntu 18 machine with apache. I have an application made in angular and an api written in Python with flask, I climbed the two to a Ubuntu machine that uses apache, the application in angular works perfectly the problem is when she tries to make a request for the api in Python, the machine is configured and all the dependencies of my api have been installed, and the same works when I make a request from the machine itself, but when the request comes from the website accessed from another machine two errors can occur: When I upload the api to localhost ( what in theory would work because the two applications are on the same machine) it generates the error: err_connection_refused When I raise the api in the machine’s ip it generates the error: err_connection_timed_out, but the api is not called at any time. I have tried running the api with both uWSGI and gunicorn, but both generate the same errors.

Follow the code of main.py

from flask import Flask
from flask_cors import CORS
from flask_restful import Api
from firebase_admin import credentials

import firebase_admin

from modals.analisaTexto import AnaliseDeTexto
from modals.converter import projetoConverte

app = Flask(__name__)
api = Api(app)
CORS(app)

cred = credentials.Certificate("./key/adminsdk.json")
firebase_admin.initialize_app(cred)


api.add_resource(projetoConverte, '/<type>/<uid>/<id_projeto>/<id_versao>', '/send', methods=['GET', 'POST'])
api.add_resource(AnaliseDeTexto, '/analise/<uid>/<id_projeto>/<id_versao>',
                 '/analise/<uid>/<id_projeto>/<id_versao>/<id_analise>', methods=['GET'])


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

I hope I didn’t get too confused.

  • You have configured WSGI to run your python API on apache?

  • I managed to solve. I used Proxypass to redirect meudominio/api requests to localhost:8000, and changed the request url in my angular project to meudominio/api, and then it started working, but thanks for the help anyway.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.