예제 #1
0
파일: views.py 프로젝트: sophieher/julython
def signup():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        user = User(form.username.data, form.email.data, form.password.data)
        db_session.add(user)
        db_session.commit()
        login_user(user)
        try:
            return redirect(url_for('home'))
        except:
            abort(500)
    return render_template('signup.html', form=form)
예제 #2
0
파일: views.py 프로젝트: sophieher/julython
def upload_file():
    form = PhotoForm()
    if request.method == 'POST':
        file = request.files[form.image.name]
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            up = UserProfile(user=current_user.id)
            up.photo = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            db_session.add(up)
            db_session.commit()
            return redirect('/')
    return render_template('photo.html', form=form)
예제 #3
0
파일: views.py 프로젝트: sophieher/julython
def add_food_mood():

    if request.method == 'POST':
        add_form = AddForm(request.form)
        if add_form.validate():
            entry = Entry(add_form.meal.data, add_form.food.data, add_form.mood.data, eater=current_user.get_id())
            db_session.add(entry)
            db_session.commit()
            return redirect('/entries/')
        else:
            abort(500)
    else:
        add_form = AddForm()

    return render_template('add.html', form=add_form)