diff --git a/run.py b/run.py index de4e6fc..76a5051 100644 --- a/run.py +++ b/run.py @@ -4,7 +4,7 @@ """ from __future__ import division, print_function, unicode_literals -import json, jsonschema, config, os, sys, logging, flask, re +import json, jsonschema, config, os, sys, logging, flask from services import db, v1, v2, utils from logging.handlers import RotatingFileHandler @@ -63,10 +63,6 @@ def log_response(sender, response): def before_request(): flask.g.get_validator = lambda: jsonschema.validators.Draft4Validator(json.load(open(schema_path))) flask.g.proxies = {'http': app.config['HTTP_PROXY'], 'https': app.config['HTTP_PROXY']} - with open("setup.py") as f: - for line in f: - if "version" in line: - flask.g.version_no = re.findall("\d+\.\d+.\d+", line) if app.config.get('DEBUG_ENDPOINTS'): @app.after_request diff --git a/services/retrieval.py b/services/retrieval.py index fcaa551..10e0dd2 100644 --- a/services/retrieval.py +++ b/services/retrieval.py @@ -1,4 +1,4 @@ -import db, json, flask +import db, json, re from utils import jsonp from flask import Response @@ -96,4 +96,8 @@ def __init__(self): class Version(Doc): def get(self): - return flask.g.version_no + with open("setup.py") as f: + for line in f: + if "version" in line: + version_no = re.findall("\d+\.\d+.\d+", line) + return version_no