Feature/common api
I think this is what we were going for? There are included files to spin up a test flask server and database to test some of the things. The main magic is in api.py though. Please let me know if this is not the direction we wanted to go in.
Merge request reports
Activity
assigned to @w2v
- src/api/flask/db/schema/test_table.sql 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/db/schema/users.sql 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/db/static/static.csv 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/db/Dockerfile 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/web/api/routes/api.py 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/web/api/database/database.py 0 → 100644
changed this file in version 7 of the diff
- src/api/flask/web/api/routes/api.py 0 → 100644
181 elif port == 15692: 182 logger.warn("Using default port: " + str(port)) 183 else: 184 logger.info("RabbitMQ port set to: " + str(port)) 185 186 r = requests.get(host) 187 if r.status_code == 200: 188 return "Healthcheck good", 200 189 else: 190 return "Healthcheck failed", r.status_code 191 192 193 @blueprint.route('/redis_healthcheck', methods=['GET']) 194 def redis_healthcheck(): 195 host = ce("REDIS_HOST", "localhost") 196 if not host: changed this line in version 7 of the diff
- src/api/flask/web/api/routes/api.py 0 → 100644
155 db_version = cursor.fetchone() 156 cursor.close() 157 conn.close() 158 if db_version: 159 return "Database is running", 200 160 else: 161 return "Database does not seem to be running", 503 162 163 except psycopg2.Error as e: 164 logger.critical("Error connecting to PostgreSQL:" + str(e)) 165 return "Error connecting to PostgreSQL:" + str(e), 503 166 167 168 @blueprint.route('/rabbitmq_healthcheck', methods=['GET']) 169 def rabbitmq_healthcheck(): 170 host = ce("RABBIT_MQ_HOST", "localhost") changed this line in version 7 of the diff
- src/api/flask/web/api/routes/api.py 0 → 100644
96 db_version = cursor.fetchone() 97 cursor.close() 98 conn.close() 99 if db_version: 100 return "Database is running", 200 101 else: 102 return "Database does not seem to be running", 503 103 104 except psycopg2.Error as e: 105 logger.critical("Error connecting to PostgreSQL:" + str(e)) 106 return "Error connecting to PostgreSQL:" + str(e), 503 107 108 109 @blueprint.route('/mssql_healthcheck', methods=['GET']) 110 def mssql_healthcheck(): 111 dbname = ce("DATABASE_DB_MS", ce("DATABASE_DB", "CommonDB")) changed this line in version 7 of the diff
- src/api/flask/web/api/routes/api.py 0 → 100644
75 76 host = ce("DATABASE_HOST", ce("DATABASE_HOST_PG", ce("PG_HOST", "localhost"))) 77 if not host: 78 return "Need to set either DATABASE_HOST_PG or DATABASE_HOST ENV variables", 503 79 elif host == 'localhost': 80 logger.warn("Using default host: " + host) 81 else: 82 logger.info("Database host set to: " + str(host)) 83 84 port = ce("DATABASE_PORT", ce("DATABASE_PORT_PW", ce("PG_PORT", 5432))) 85 if not port: 86 return "Need to set either DATABASE_PORT_PG or DATABASE_PORT ENV variables", 503 87 elif port == 5432: 88 logger.warn("Using default port: " + str(port)) 89 else: 90 logger.info("Database port set to: " + str(port)) changed this line in version 7 of the diff
3 from routes import api as api_routes 4 5 import flask 6 from flask import request 7 8 api = Namespace('api', 'Loads Hello World' ) 9 10 @api.route("/") 11 @api.doc() 12 class GetBaseRoute(Resource): 13 def get(self): 14 return api_routes.home() 15 16 # TODO 17 # Make swagger from flask-restx 18 # make swagger from fast-api changed this line in version 7 of the diff
changed this file in version 7 of the diff