Skip to content
Snippets Groups Projects
Commit 30478e00 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

client: debug prints ans version.json (v1.0.0)

parent d9e0922d
No related branches found
No related tags found
No related merge requests found
......@@ -2,13 +2,17 @@ import json
from datetime import datetime
import requests
from flask import Flask, render_template, redirect
from flask import Flask, render_template, redirect, jsonify
from gevent.pywsgi import WSGIServer
from Localization import LOCALIZATION
from UrlBuilder import UrlBuilder
from blueprints import Roadmaps, Authentication, Milestones, Tasks, SubTasks
with open('version.json', 'r') as f:
VERSION = json.load(f)
VERSION = VERSION['version']
with open('settings.json', 'r') as f:
SETTINGS = json.load(f)
......@@ -26,6 +30,11 @@ app.register_blueprint(Tasks.construct_blueprint(URL_BUILDER))
app.register_blueprint(SubTasks.construct_blueprint(URL_BUILDER))
@app.route('/version', methods=['GET'])
def version():
return jsonify(VERSION)
@app.route('/')
def overview():
roadmaps = requests.get(URL_BUILDER.build_url('roadmaps')).json()
......@@ -39,36 +48,36 @@ def roadmap():
@app.route('/roadmap/<roadmapID>')
def roadmap_by_id(roadmapID):
try:
roadmapID = int(roadmapID)
except ValueError:
return render_template('error.html', message=LOCALIZATION['error_param_invalid'])
if roadmapID < 1:
return render_template('error.html', message=LOCALIZATION['error_param_invalid'])
roadmap = requests.get(URL_BUILDER.build_url('roadmap', roadmapID, 'full')).json()
if roadmap is None:
return render_template('error.html', message=LOCALIZATION['error_roadmap_not_existing'])
success, response = __check_roadmap(roadmapID)
if success:
return render_template('index.html', roadmap=response, localization=LOCALIZATION)
return render_template('index.html', roadmap=roadmap, localization=LOCALIZATION)
return response
@app.route('/roadmap/<roadmapID>/fragment')
def roadmap_fragement_by_id(roadmapID):
success, response = __check_roadmap(roadmapID)
if success:
return render_template('roadmapFragment.html', roadmap=response, localization=LOCALIZATION)
return response
def __check_roadmap(roadmapID):
try:
roadmapID = int(roadmapID)
except ValueError:
return render_template('error.html', message=LOCALIZATION['error_param_invalid'])
return False, render_template('error.html', message=LOCALIZATION['error_param_invalid'])
if roadmapID < 1:
return render_template('error.html', message=LOCALIZATION['error_param_invalid'])
return False, render_template('error.html', message=LOCALIZATION['error_param_invalid'])
roadmap = requests.get(URL_BUILDER.build_url('roadmap', roadmapID, 'full')).json()
if roadmap is None:
return render_template('error.html', message=LOCALIZATION['error_roadmap_not_existing'])
return False, render_template('error.html', message=LOCALIZATION['error_roadmap_not_existing'])
return render_template('roadmapFragment.html', roadmap=roadmap, localization=LOCALIZATION)
return True, roadmap
if __name__ == '__main__':
......@@ -80,5 +89,6 @@ if __name__ == '__main__':
else:
http_server = WSGIServer((SETTINGS['listen'], SETTINGS['port']), app)
print('Listening on {}:{}...'.format(SETTINGS['listen'], SETTINGS['port']))
print('RoadmapClient {}({}) - Listening on {}:{}...'.format(VERSION['name'], VERSION['code'],
SETTINGS['listen'], SETTINGS['port']))
http_server.serve_forever()
{
"version": {
"name": "v1.0.0",
"code": 1,
"date": "30.07.19"
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment