【发布时间】:2021-07-19 11:55:45
【问题描述】:
这就是我想要做的事情。我保存在数据库中的图像将进入正确的路径。但他们没有出现在网站上。
@blogs.route("/post/new", methods=['GET', 'POST'])
def new_post():
if ('user' in session and session['user'] == params["username"]):
form = PostForm()
if form.validate_on_submit():
pic = save_picture(request.files['pic'])
post = Post(title=form.title.data,
content=form.content.data, img=pic)
db.session.add(post)
db.session.commit()
flash('Your post has been created!', 'success')
image_file = url_for('static', filename = 'profile_pics/' + pic)
return render_template('post.html',image_file=image_file)
return render_template('create_post.html', title='New Post',
form=form)
return "please login to the dashboard first. Dont try to enter without logging in!"
HTML 方面
<img src="{{image_file}}" alt="error">
【问题讨论】:
-
那行不通..
标签: html python-3.x flask jinja2