From 321b4fb49cba4f65f9e81544c6caaec0e55e276e Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 8 Dec 2024 07:18:59 -0500 Subject: [PATCH] Added more backend --- services/web/project/__init__.py | 15 ++++++++++++++- services/web/requirements.txt | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/web/project/__init__.py b/services/web/project/__init__.py index 7d1fca1..db3ea9c 100644 --- a/services/web/project/__init__.py +++ b/services/web/project/__init__.py @@ -1,4 +1,6 @@ import os +import psycopg2 +from dotenv import load_dotenv from flask import ( Flask, @@ -9,6 +11,7 @@ from flask import ( from flask_sqlalchemy import SQLAlchemy from werkzeug.utils import secure_filename +load_dotenv() app = Flask(__name__) app.config.from_object("project.config.Config") @@ -25,13 +28,23 @@ class User(db.Model): def __init__(self, email): self.email = email +dataUrl = os.getenv("DATABASE_URL") +connection = psycopg2.connect(dataUrl) + @app.route("/") def hello_world(): - return jsonify(hello="ameye world") + GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;""" + with connection: + with connection.cursor() as cursor: + cursor.execute(GLOBAL_AVG) + account = cursor.fetchone() + #return jsonify(hello="ameye world") + return {"account": account} @app.route("/auth/login") def statrt_login(): + return jsonify(hello="ameye world") @app.route("/auth/register") diff --git a/services/web/requirements.txt b/services/web/requirements.txt index 1cfdce1..b21f7f8 100644 --- a/services/web/requirements.txt +++ b/services/web/requirements.txt @@ -3,4 +3,5 @@ Flask-SQLAlchemy==3.0.3 gunicorn==20.1.0 psycopg2-binary==2.9.6 flask-smorest==0.42.3 -psycopg2-binary \ No newline at end of file +python-dotenv +python-jwt \ No newline at end of file