Python app.app.route() Examples
The following are 5
code examples of app.app.route().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
app.app
, or try the search function
.
Example #1
Source File: content_views.py From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #2
Source File: views.py From stack with MIT License | 5 votes |
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))
Example #3
Source File: views.py From stack with MIT License | 5 votes |
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))
Example #4
Source File: views.py From stack with MIT License | 5 votes |
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))
Example #5
Source File: routes.py From wb_contest_submission_server with GNU General Public License v3.0 | 5 votes |
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)