Skip to content

Commit 5ec7ec7

Browse files
committed
feat: add a simple version endpoint /version
1 parent 2df8d63 commit 5ec7ec7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/server/_config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55

66
load_dotenv()
77

8+
VERSION = "0.1.0"
89

910
MAX_RESULTS = int(10e6)
1011
MAX_COMPATIBILITY_RESULTS = int(3650)
1112

1213
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite:///test.db")
13-
SQLALCHEMY_ENGINE_OPTIONS = json.loads(
14-
os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}")
15-
)
16-
SECRET = os.environ.get("FLASK_SECRET", 'secret')
17-
URL_PREFIX = os.environ.get('FLASK_PREFIX', '/')
14+
SQLALCHEMY_ENGINE_OPTIONS = json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}"))
15+
SECRET = os.environ.get("FLASK_SECRET", "secret")
16+
URL_PREFIX = os.environ.get("FLASK_PREFIX", "/")
1817

1918
AUTH = {
2019
"twitter": os.environ.get("SECRET_TWITTER"),

src/server/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import logging
33
from typing import Dict, Callable
44

5-
from flask import request, send_file, Response, send_from_directory
5+
from flask import request, send_file, Response, send_from_directory, jsonify
66

7-
from ._config import URL_PREFIX
7+
from ._config import URL_PREFIX, VERSION
88
from ._common import app, set_compatibility_mode
99
from ._exceptions import MissingOrWrongSourceException
1010
from .endpoints import endpoints
@@ -39,6 +39,11 @@ def send_index_file():
3939
return send_file(pathlib.Path(__file__).parent / "index.html")
4040

4141

42+
@app.route(f"{URL_PREFIX}/version")
43+
def send_version():
44+
return jsonify(dict(version=VERSION))
45+
46+
4247
@app.route(f"{URL_PREFIX}/lib/<path:path>")
4348
def send_lib_file(path: str):
4449
return send_from_directory(pathlib.Path(__file__).parent / "lib", path)

0 commit comments

Comments
 (0)