Skip to content
Snippets Groups Projects
Select Git revision
  • 48ce515dc09c8c6576be07a02aeee04b428a542b
  • develop default
  • master
3 results

printer.py

Blame
  • Forked from Hodor Security Project / Hodor Web Backend
    Source project has a limited visibility.
    printer.py 754 B
    # -*- coding: utf-8 -*-
    from hodor import app
    from flask import render_template, request
    from flask_wtf import FlaskForm
    from wtforms import StringField
    from wtforms.validators import DataRequired
    
    
    class CreateForm(FlaskForm):
        text = StringField('name', validators=[DataRequired()])
    
    
    @app.route('/')
    def start():
        return render_template('printer/index.html')
    
    
    @app.route('/print', methods=['GET', 'POST'])
    def printer():
        form = CreateForm(request.form)
        if request.method == 'POST' and form.validate():
            from hodor.models.Printer import Printer
            printer = Printer()
            printer.show_string(form.text.data)
            return render_template('printer/index.html')
        return render_template('printer/print.html', form=form)