当前位置: 首页>>代码示例>>Python>>正文


Python app.route方法代码示例

本文整理汇总了Python中app.app.route方法的典型用法代码示例。如果您正苦于以下问题:Python app.route方法的具体用法?Python app.route怎么用?Python app.route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.app的用法示例。


在下文中一共展示了app.route方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: view

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import route [as 别名]
def view():
	req_url = request.args.get('url')
	if not req_url:
		return render_template('error.html', title = 'Viewer', message = "Error! No page specified!")
	version = request.args.get('version')

	if version:
		return render_template('error.html', title = 'Error', message = "Historical views must be routed through the /history route!")

	response = make_response(render_template('view.html', title = 'Rendering Content', req_url = req_url, version=None))
	return set_cache_control_headers(response, allow_inline=True) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:13,代码来源:content_views.py

示例2: collector_control

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import route [as 别名]
def collector_control(collector_id):
    """
    POST control route for collector forms
    """
    collector_form = ProcessControlForm(request.form)
    task = None

    # On form submit controls the processor
    if request.method == 'POST' and collector_form.validate():
        command = request.form['control'].lower()

        task_args = {
            'process': 'collect',
            'project': g.project,
            'collector_id': collector_id
        }

        db = DB()
        collector = db.get_collector_detail(g.project['project_id'], collector_id)
        network = collector['collector']['network']

        if command == 'start':
            task = start_daemon.apply_async(kwargs=task_args, queue='stack-start')
        elif command == 'stop':
            task = stop_daemon.apply_async(kwargs=task_args, queue='stack-stop')
        elif command == 'restart':
            task = restart_daemon.apply_async(kwargs=task_args, queue='stack-start')

        return redirect(url_for('collector',
                                project_name=g.project['project_name'],
                                network=network,
                                collector_id=collector_id,
                                task_id=task.task_id)) 
开发者ID:bitslabsyr,项目名称:stack,代码行数:35,代码来源:views.py

示例3: processor_control

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import route [as 别名]
def processor_control(network):
    """
    POST control route for processor forms
    """
    processor_form = ProcessControlForm(request.form)
    task = None

    # On form submit controls the processor
    if request.method == 'POST' and processor_form.validate():
        command = request.form['control'].lower()

        task_args = {
            'process': 'process',
            'project': g.project,
            'network': network
        }

        if command == 'start':
            task = start_daemon.apply_async(kwargs=task_args, queue='stack-start')
        elif command == 'stop':
            task = stop_daemon.apply_async(kwargs=task_args, queue='stack-stop')
        elif command == 'restart':
            task = restart_daemon.apply_async(kwargs=task_args, queue='stack-start')

    return redirect(url_for('network_home',
                            project_name=g.project['project_name'],
                            network=network,
                            processor_task_id=task.task_id)) 
开发者ID:bitslabsyr,项目名称:stack,代码行数:30,代码来源:views.py

示例4: inserter_control

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import route [as 别名]
def inserter_control(network):
    """
    POST control route for inserter forms
    """
    inserter_form = ProcessControlForm(request.form)
    task = None

    # On form submit controls the processor
    if request.method == 'POST' and inserter_form.validate():
        command = request.form['control'].lower()

        task_args = {
            'process': 'insert',
            'project': g.project,
            'network': network
        }

        if command == 'start':
            task = start_daemon.apply_async(kwargs=task_args, queue='stack-start')
        elif command == 'stop':
            task = stop_daemon.apply_async(kwargs=task_args, queue='stack-stop')
        elif command == 'restart':
            task = restart_daemon.apply_async(kwargs=task_args, queue='stack-start')

    return redirect(url_for('network_home',
                            project_name=g.project['project_name'],
                            network=network,
                            inserter_task_id=task.task_id)) 
开发者ID:bitslabsyr,项目名称:stack,代码行数:30,代码来源:views.py

示例5: submit_candidate

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import route [as 别名]
def submit_candidate():
    now = int(time.time())
    if now < app.config['STARTING_DATE']:
        return render_template('submit_candidate_before_starting_date.html',
                               active_page='submit_candidate',
                               starting_date=utils.format_timestamp(app.config['STARTING_DATE']))
    if now > app.config['POSTING_DEADLINE']:
        return render_template('submit_candidate_deadline_exceeded.html',
                               active_page='submit_candidate',
                               posting_deadline=utils.format_timestamp(app.config['POSTING_DEADLINE']))
    form = WhiteboxSubmissionForm()
    if request.method != 'POST':
        return render_template('submit_candidate.html', form=form, active_page='submit_candidate', testing=app.testing)
    elif not form.validate_on_submit():
        return render_template('submit_candidate.html', form=form, active_page='submit_candidate', testing=app.testing), 400
    else:
        upload_folder = app.config['UPLOAD_FOLDER']
        basename = ''.join(random.SystemRandom().choice(
            string.ascii_lowercase + string.digits) for _ in range(32))
        filename = basename + '.c'
        key = form.key.data
        compiler = form.compiler.data
        form_data = form.program.data
        form_data.save(os.path.join(upload_folder, filename))
        Program.create(basename=basename,
                       key=key,
                       compiler=compiler,
                       user=current_user)
        db.session.commit()
        return redirect(url_for('submit_candidate_ok'))


# This route is called directly when the user has js activated (see file-progress.js) 
开发者ID:CryptoExperts,项目名称:wb_contest_submission_server,代码行数:35,代码来源:routes.py


注:本文中的app.app.route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。