From 011ea38fa8c5508625faca9926fa6843078bc84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Gon=C3=A7alves=20Costa?= <20251144030032@ifrn.local> Date: Fri, 22 May 2026 21:12:35 -0300 Subject: [PATCH] =?UTF-8?q?Configura=C3=A7=C3=A3o=20do=20produto=20n=C3=A3?= =?UTF-8?q?o=20encontrado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apirest/.env.example | 7 +++++++ apirest/__pycache__/db.cpython-311.pyc | Bin 904 -> 904 bytes apirest/app.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 apirest/.env.example diff --git a/apirest/.env.example b/apirest/.env.example new file mode 100644 index 0000000..5e625a7 --- /dev/null +++ b/apirest/.env.example @@ -0,0 +1,7 @@ +port=5000 + +DB_HOST= +DB_USER=root +DB_PASSWORD= +DB_NAME=loja_redes +DB_PORT=3306 \ No newline at end of file diff --git a/apirest/__pycache__/db.cpython-311.pyc b/apirest/__pycache__/db.cpython-311.pyc index 257bc86e781048c1842db643972a270bf8b26cd7..e6131438e3374334d2a51772016f5cd33ff8c52b 100644 GIT binary patch delta 56 zcmeBR?_lR%&dbZi00dpv1vYXkGRYYk7?~OxnwS_E8yFZH#kiyvXP4v`#H6H_#pk7# KZ1!TZV*~(n)DF`C delta 56 zcmeBR?_lR%&dbZi00bZQv2Wy7WRf#9H!?9WGK+CZEzT~",methods=["GET"]) +def listar_produtos_id(id): + conexao = get_connection() + cursor = conexao.cursor(dictionary=True) + + cursor.execute("Select * from produto where id = %s", (id,)) + produto = cursor.fetchone() + + cursor.close() + conexao.close() + + if produto is None: + return jsonify({"erro" : "Produto não encontrado"}), 404 + + return jsonify(produto) + #Inicializa o servidor da APIRest if __name__ == "__main__": app.run(port=PORT, debug=True) \ No newline at end of file