Skip to content

Commit

Permalink
refactor to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Dec 13, 2024
1 parent c601ef8 commit 939415b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions backend/app/getGitHash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from subprocess import check_output

def getGitHash():
return check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
7 changes: 3 additions & 4 deletions backend/app/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json, re
from subprocess import check_output
from datetime import datetime
from flask import jsonify, request
from app import app
Expand All @@ -9,7 +8,7 @@
from app.get_travel_time import get_travel_time
from app.get_here_links import get_here_links
from app.get_centreline_links import get_centreline_links

from app.getGitHash import getGitHash
@app.route('/')
def index():
"""Provide basic documentation about the available resources.
Expand All @@ -27,10 +26,10 @@ def index():
})

@app.route('/version')
def getGitHash():
def version():
"""Return the Git hash of the application"""
return jsonify({
'git-hash': check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
'git-hash': getGitHash()
})

# test URL /closest-node/-79.3400/43.6610
Expand Down

0 comments on commit 939415b

Please sign in to comment.