コード例 #1
0
ファイル: routes.py プロジェクト: seantibor/challenges
def data_enter():
    form = TextForm()
    if form.validate_on_submit():
        title = request.form['title']
        text = request.form['text']

        signature = Something(title=title, text=text)
        db.session.add(signature)
        db.session.commit()
        return redirect('/list')
    return render_template('data_enter.html', form=form)
コード例 #2
0
    def add_text(board_slug):
        print 'add_text: ', board_slug
        board = Board.query.filter_by(slug=board_slug).first()
        if not board:
            abort(404)

        form = TextForm()
        if form.validate_on_submit():
            response_data = process_text(board, form.text.data)
            db.session.commit()
            return json_success(response_data)

        return json_error_message('Failed to create color',
                                  error_data=form.errors)
コード例 #3
0
ファイル: routes.py プロジェクト: StudioCreate/spire
    def add_text(board_slug):
        print 'add_text: ', board_slug
        board = Board.query.filter_by(slug=board_slug).first()
        if not board:
            abort(404)

        form = TextForm()
        if form.validate_on_submit():
            response_data = process_text(board, form.text.data)
            db.session.commit()
            return json_success(response_data)

        return json_error_message('Failed to create color',
                                  error_data=form.errors)
コード例 #4
0
def text():
    form = TextForm()
    dform = DownloadForm()
    if form.validate_on_submit():
        algo = form.algo.data
        text = form.text.data
        num = form.sentences.data
        result = select_algorithm(algo, text, num)

        return render_template('text_input.html',
                               title='Text',
                               results=result,
                               form=form,
                               dform=dform)
    return render_template('text_input.html', title='Text', form=form)
コード例 #5
0
def index():
    global text, delimiter
    form = TextForm()
    if form.validate_on_submit():
        text = form.text.data
        delimiter = form.delimiters.data
        operation = form.operations.data
        operation_name = None
        if (operation == 'a'):
            operation_name = 'wordcount'
        elif (operation == 'b'):
            operation_name = 'charactercount'
        elif (operation == 'c'):
            operation_name = 'mostfrequent5words'

        return redirect(url_for('showresult', operationname=operation_name))
    return render_template('index.html', title='Home', form=form)