Пример #1
0
def add_entry():
    try:
        if request.method == 'POST':
            app.logger.info("hoge")
            app.logger.info("lat: " + request.form['lat'])
            app.logger.info("long: " + request.form['long'])
            app.logger.info("timestamp: " + request.form['timestamp'])
            app.logger.info("client: " + request.form['client'])

            entry = Entry(lat=request.form['lat'],
                          long=request.form['long'],
                          timestamp=int(request.form['timestamp']),
                          client=request.form['client'])
            app.logger.info(entry)

        else:
            entry = Entry(lat=request.args.get('lat', ''),
                          long=request.args.get('long', ''),
                          timestamp=int(
                              request.args.get('timestamp', time.time())),
                          client=request.args.get('client', ''))

    except Exception as e:
        return str(e)

    db.session.add(entry)
    db.session.commit()
    flash('New entry was successfully posted')
    return redirect(url_for('show_entries'))
Пример #2
0
def show_entries():
    if current_user.is_authenticated():
        entry = Entry()
        form = EntryForm(obj=entry)
        if form.validate_on_submit():
            form.populate_obj(entry)
            entry.save()
            flash("Added entry")
            return redirect(url_for('.show_entries'))
        elif form.is_submitted():
            flash("Invalid data")
    else:
        form = None

    entries = Entry.query.all()
    return render_template('show_entries.html', entries=entries, add_form=form)
Пример #3
0
def add_entry():
    entry = Entry(
        title = request.form['title'],
        text = request.form['text']
    )
    db.session.add(entry)
    db.session.commit()
    flash('新規投稿に成功しました')
    return redirect(url_for('show_entries'))
Пример #4
0
def add_entry():
    entry = Entry(
            title=request.form['title'],
            text=request.form['text']
            )
    db.session.add(entry)
    db.session.commit()
    flash('New entry was successfully posted')
    return redirect(url_for('show_entries'))
Пример #5
0
def add_entry():
    # request: HTTPリクエストオブジェクトmethodやフォームデータにアクセスできる
    entry = Entry(title=request.form['title'], text=request.form['text'])
    db.session.add(entry)
    db.session.commit()
    # メッセージを通知するための仕組み
    flash('New entry was successfully posted.')
    # redirect: 指定したURLにリダイレクトするレスポンスを返す
    # url_for:  指定したエンドポイントに対するURLを返す
    return redirect(url_for('show_entries'))
Пример #6
0
def add_entry():
    if not session.get('logged_in'):
        abort(401)
    asset = Asset(request.form['media'], request.form['credit'],
                  request.form['caption'])
    entry = Entry(request.form['headline'], request.form['startDate'],
                  request.form['endDate'], request.form['text'], asset)
    db.session.add(entry)
    db.session.commit()
    flash('New entry was successfully posted')
    return redirect(url_for('show_entries'))
Пример #7
0
def add_entry():
    entry = Entry(username=request.form['username'],
                  title=request.form['title'],
                  text=request.form['text'],
                  image=request.form['image'],
                  usernames=session['usernames'])
    db.session.add(entry)
    db.session.commit()
    print(request.form['image'])
    flash("commited!!!")
    return redirect(url_for('show_entries'))
Пример #8
0
def create():
    form = EntryForm()
    if form.validate_on_submit():
        entry = Entry()
        form.populate_obj(entry)
        db.session.add(entry)
        try:
          db.session.commit()
          flash('Entry created correctly.', 'success')
          return redirect(url_for('entres.index'))
        except:
          db.session.rollback()
          flash('Error generating entry!', 'danger')
    return render_template('entres/create.pug', form=form)
Пример #9
0
def edit(id):
    entry = Entry.query.filter_by(id=id).first()
    form = EntryForm(obj=entry)
    if form.validate_on_submit():
        entry = Entry()
        form.populate_obj(entry)
        db.session.add(entry)
        try:
          db.session.commit()
          flash('Entry saved successfully.', 'success')
          return redirect(url_for('entres.index'))
        except:
          db.session.rollback()
          flash('Error update entry!', 'danger')
    return render_template('entres/edit.pug', form=form)
Пример #10
0
def add_answer():
    id = 10
    q1 = request.form['q1']
    q2 = request.form['q2']
    q3 = request.form['q3']
    q4 = request.form['q4']
    q5 = request.form['q5']
    q6 = request.form['q6']
    q7 = request.form['q7']
    q8 = request.form['q8']
    q9 = request.form['q9']
    q10 = request.form['q10']

    entry = Entry(id=id,
                  q1=q1,
                  q2=q2,
                  q3=q3,
                  q4=q4,
                  q5=q5,
                  q6=q6,
                  q7=q7,
                  q8=q8,
                  q9=q9,
                  q10=q10)
    db.session.add(entry)
    #db.session.commit()

    x = np.array([
        int(q1),
        int(q2),
        int(q3),
        int(q4),
        int(q5),
        int(q6),
        int(q7),
        int(q8),
        int(q9),
        int(q10)
    ])

    scores = {"np": x[0], "cp": x[1], "ac": x[2], "a": x[3], "fc": x[4]}

    result = {"result": algo_ego2(scores)}

    return jsonify(result)
Пример #11
0
def add_entry():
    entry = Entry(title=flask.request.form['title'],
                  text=flask.request.form['text'])
    db.session.add(entry)
    db.session.commit()
    return flask.redirect(flask.url_for('show_entries'))
Пример #12
0
def add_entry():
    entry = Entry(title=request.form["title"], text=request.form["text"])
    db.session.add(entry)
    db.session.commit()
    flash("New entry was successfully posted")
    return redirect(url_for("show_entries"))