forked from salimane/flask-mvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinter.py
More file actions
24 lines (18 loc) · 706 Bytes
/
Copy pathprinter.py
File metadata and controls
24 lines (18 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
from project import app
from flask import render_template, request
from flask.ext.wtf import Form, TextField, validators
class CreateForm(Form):
text = TextField(u'Text:', [validators.Length(min=1, max=20)])
@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 project.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)