本文整理匯總了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)
示例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))
示例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))
示例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))
示例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)