From eb06a6d09e8e5c38d3698e08490f02f52ccf7db5 Mon Sep 17 00:00:00 2001 From: duzzsys Date: Fri, 22 May 2020 02:05:22 -0300 Subject: [PATCH] =?UTF-8?q?Adicionando=20configura=C3=A7=C3=A3o=20de=20BIN?= =?UTF-8?q?D=20SERVER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf.cfg | 2 ++ rotas.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/conf.cfg b/conf.cfg index 8f47c09..45f4ee9 100644 --- a/conf.cfg +++ b/conf.cfg @@ -1,4 +1,6 @@ [config_server] +server_address = 127.0.0.1 +server_port = 5000 devs = "Jonas Duarte, Pablo Mariz" [config_bank_app] diff --git a/rotas.py b/rotas.py index cf091d6..4f2a2cc 100644 --- a/rotas.py +++ b/rotas.py @@ -3,11 +3,21 @@ #__author__ = Pablo Mariz, souzamariz27@gmail.com #Python3 +import configparser from flask import Flask, jsonify, request from model import Backend app = Flask(__name__) backend = Backend() +def bind_server(): + config = configparser.ConfigParser() + config.read('conf.cfg') + + server_address = config.get('config_server', 'server_address') + server_port = config.get('config_server', 'server_port') + + return [server_address, server_port] + #adicionar novo motorista - FUNCIONANDO @app.route('/novo_veiculo', methods=['POST']) def novo_veiculo(): @@ -416,4 +426,5 @@ def realizar_logoff(): if __name__ == "__main__": - app.run(debug=True) + server_address, server_port = bind_server() + app.run(host=server_address, port=server_port)