Skip to content

Commit

Permalink
Add version checking feature to footer
Browse files Browse the repository at this point in the history
  • Loading branch information
lklynet committed Jan 13, 2025
1 parent b20382d commit ffe0dae
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,37 @@
app = Flask(__name__, static_folder="static")

def get_version_from_git():
"""Fetch the most recent Git tag as the version."""
try:
# Get the most recent Git tag (e.g., v2.0.0)
version = subprocess.check_output(["git", "describe", "--tags"]).strip().decode("utf-8")
# Run `git describe` in the correct working directory
version = subprocess.check_output(
["git", "describe", "--tags"], cwd=os.getcwd()
).strip().decode("utf-8")
print(f"Fetched version: {version}") # Debugging log
return version
except subprocess.CalledProcessError as e:
print(f"Error executing git command: {e}")
return "Unknown"
except FileNotFoundError:
# Handle cases where Git is not available in the environment
print("Git command not found. Ensure Git is installed and available.")
return "Unknown"
except Exception as e:
print(f"Error fetching version: {e}")
print(f"Unexpected error while fetching version: {e}")
return "Unknown"

# Fetch version on application startup
DASHLY_VERSION = get_version_from_git()

@app.route("/version")
def get_version():
"""Return the current application version."""
return jsonify({"version": DASHLY_VERSION})

if __name__ == "__main__":
from waitress import serve
serve(app, host="0.0.0.0", port=8080)

SETTINGS_FILE = os.getenv("USER_SETTINGS_FILE", "/app/data/settings.json")
READ_ONLY_DB_PATH = os.getenv("NGINX_DB_PATH", "/nginx/database.sqlite")

Expand Down

0 comments on commit ffe0dae

Please sign in to comment.