我的SELECT A.* FROM USERS A INNER JOIN
(SELECT user_id, COUNT(*) FOLLOW_COUNT
FROM FOLLOW GROUP BY user_id ORDER BY
COUNT(*) DESC LIMIT 5) B
ON A.user_id=B.user_id;
上有这段代码:
app.py
在我的from werkzeug import secure_filename
from flask import Flask, render_template, request
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES
app = Flask(__name__, template_folder='../templates')
photos = UploadSet('photos', IMAGES)
app.config['UPLOADED_PHOTOS_DEST'] = 'static/img'
configure_uploads(app, photos)
@app.route('/')
def hello():
return "Hello World!"
@app.route('/upload', methods=['GET', 'POST'])
def upload():
if request.method == 'POST' and 'photo' in request.files:
filename = photos.save(request.files['photo'])
return 'static/img/'+str(secure_filename(filename))#filename =
return render_template('upload.html')
if __name__ == '__main__':
app.run(debug=True)
:
upload.html
现在,它只显示上次上传图片的文件名,那么,我该如何实际显示图片而不是图片名称呢?
有关详细信息,请参阅我的<html>
<head>
<title>Upload</title>
</head>
<body>
<form method=POST enctype=multipart/form-data action="{{ url_for('upload') }}">
<input type=file name=photo>
<input type="submit">
</form>
</body>
</html>
:
routes.py
修改
我使用了另一个答案,但它不符合我的需求,因为我仍然面临错误404,所以我认为这与我的from app import app
@app.route('/upload')
def upload():
return upload
和POST
请求有关
也许我应该将它们分别用于不同的功能?