예제 #1
0
파일: views.py 프로젝트: asmcos/blog
def index():
	blog = blogs.all();
	form = BlogsForm();
	if request.method == 'POST':
		flag = form.validate(request.params)
		if flag:
			n = blogs(**form.data);
			n.username = request.user.username
			n.save();
	return {'blog':blog,'form':form}
예제 #2
0
파일: route.py 프로젝트: sunidhibn/Blog
def info():
    if request.method == 'POST':
        new_user = blogs()
        new_user.username = request.form['user_name']
        new_user.content = request.form['content']
        new_user.title = request.form['title']
        new_user.save()
        return redirect('/')
    else:
        posts = blogs.select().order_by(blogs.posttime.desc())
        return render_template("home.html", posts=posts)
예제 #3
0
def create():
    if require_login():
        return redirect(url_for(login))

    if request.method == "POST":
        form = BlogsForm()
        flag = form.validate(request.params)
        if flag:
            info = blogs(**form.data)
            info.username = request.user.username
            info.save()
        return redirect('/view/%d' % info.id)

    form = BlogsForm()
    return {'form':form}