70 lines
2.3 KiB
Python
Raw Normal View History

2015-03-27 15:27:47 +01:00
#!/usr/bin/python
# Copyright (c) 2015 SUSE Linux Products GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import os
import sys
from abichecker_dbmodel import *
2015-05-22 15:36:15 +02:00
from abichecker_common import CACHEDIR
2015-03-27 15:27:47 +01:00
from flask import Flask, request, session, url_for, redirect, \
render_template, send_file, abort, g, flash, _app_ctx_stack
app = Flask(__name__)
app.config.from_object(__name__)
#app.cli.command('initdb')
#def initdb_command():
# """Creates the database tables."""
# Base.metadata.create_all(db_engine())
@app.route('/')
def list():
session = db_session()
2015-05-22 11:13:27 +02:00
requests = session.query(Request).order_by(Request.id.desc()).limit(200).all()
2015-03-27 15:27:47 +01:00
return render_template('index.html', requests = requests)
2015-03-27 15:27:47 +01:00
@app.route('/request/<int:request_id>')
def request(request_id):
session = db_session()
request = session.query(Request).filter(Request.id == request_id).one()
2015-03-27 15:27:47 +01:00
return render_template('request.html', request = request)
2015-03-27 15:27:47 +01:00
@app.route('/report/<int:report_id>')
def report(report_id):
2015-03-27 15:27:47 +01:00
session = db_session()
report = session.query(LibReport).filter(LibReport.id == report_id).one()
2015-03-27 15:27:47 +01:00
fn = os.path.join(CACHEDIR, report.htmlreport)
return send_file(fn)
2015-05-19 11:29:51 +02:00
application = app
2015-03-27 15:27:47 +01:00
if __name__ == '__main__':
Base.metadata.create_all(db_engine())
2015-05-19 11:29:51 +02:00
application.run(debug=True)
2015-03-27 15:27:47 +01:00
# vim: sw=4 et