コード例 #1
0
def render_pdf(options):
    """Generate a PDF report for a given group of samples."""
    group_id = options['report']['group']
    url = "/groups/{}".format(group_id)

    # spin up the Flask server
    config = DefaultConfig
    report_options = options['report']
    config.CHANJO_URI = options.get('database')
    panel_name = report_options.get('panel_name')
    config.CHANJO_LANGUAGE = report_options.get('language')
    config.CHANJO_PANEL = report_options.get('panel')

    app = create_app(config=config)
    with app.test_request_context(base_url='http://localhost/'):
        url = url_for('report.group', group_id=group_id, panel_name=panel_name)
        # /hello/ is resolved relative to the context’s URL.
        return HTML(url).write_pdf()
コード例 #2
0
ファイル: html.py プロジェクト: zixuedanxin/chanjo-report
def render_html(options):
    """Start a Flask server to generate HTML report on request."""
    # spin up the Flask server
    config = ProdConfig
    config.SQLALCHEMY_DATABASE_URI = options['database']
    report_options = options['report']
    config.CHANJO_PANEL_NAME = report_options.get('panel_name')
    config.CHANJO_LANGUAGE = report_options.get('language')
    config.CHANJO_PANEL = report_options.get('panel')
    config.DEBUG = report_options.get('debug')

    app = create_app(config=config)
    host = report_options.get('host', '0.0.0.0')
    port = report_options.get('port', 5000)
    click.echo(
        click.style("open browser to: http://{}:{}".format(host, port),
                    fg='blue'))
    app.run(host=host, port=port)
コード例 #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask.ext.script import Manager, Server

from chanjo_report.server.app import create_app

app = create_app()
manager = Manager(app)


manager.add_command('vagrant', Server(host='0.0.0.0', use_reloader=True))


if __name__ == '__main__':
    manager.run()
コード例 #4
0
# -*- coding: utf-8 -*-
import os

from chanjo_report.server.app import create_app


class Config:
    SQLALCHEMY_DATABASE_URI = os.environ['SQLALCHEMY_DATABASE_URI']
    SQLALCHEMY_TRACK_MODIFICATIONS = False


application = create_app(config=Config)