|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | # NOTE: pass -d to this to print debugging info when the server crashes.
|
3 | 3 | from flask import Flask, render_template, url_for, request
|
4 |
| -from subprocess import Popen, PIPE, check_call |
| 4 | +from subprocess import Popen, PIPE, check_call, check_output |
5 | 5 | import sys, os, string, glob, logging, pathlib
|
6 | 6 |
|
7 | 7 | app = Flask(__name__)
|
8 | 8 |
|
9 | 9 | app.logger.addHandler(logging.StreamHandler(sys.stdout))
|
10 | 10 | app.logger.setLevel(logging.ERROR)
|
11 | 11 |
|
| 12 | +# Git commit hash for easy version checking |
| 13 | +version = "" |
| 14 | +if os.path.isfile("version.txt"): |
| 15 | + with open("version.txt", "r") as f: |
| 16 | + version = f.readline().strip() |
| 17 | +else: |
| 18 | + version = check_output(["git", "describe", "--tags", "--always"]).decode("utf-8") |
| 19 | + |
12 | 20 | def compileO():
|
13 | 21 | r = check_call(['make', 'ide'])
|
14 | 22 | print("o-ide: " + "".join(glob.glob("oide*")))
|
@@ -38,12 +46,12 @@ def index():
|
38 | 46 | #Output to IDE
|
39 | 47 | if p.returncode:
|
40 | 48 | print('Output:', output, 'error:', error)
|
41 |
| - return render_template('error.html', code=code, input=input, error=error) |
| 49 | + return render_template('error.html', version=version, code=code, input=input, error=error) |
42 | 50 | else:
|
43 | 51 | print('Output:', output, 'stack:', error)
|
44 |
| - return render_template('code.html', code=code, input=input, output=output, stack=error or '[]') |
| 52 | + return render_template('code.html', version=version, code=code, input=input, output=output, stack=error or '[]') |
45 | 53 | else:
|
46 |
| - return render_template('primary.html') |
| 54 | + return render_template('primary.html', version=version) |
47 | 55 |
|
48 | 56 | @app.route('/link/')
|
49 | 57 | @app.route('/link/<code>/')
|
|
0 commit comments