Flask_Restful 渲染模版
code
#coding=utf-8 from flask import Flask,Response,jsonify,render_template,send_from_directory,make_response from flask_restful import Api, Resource, reqparse,request from werkzeug.datastructures import FileStorage import os import json import datetime #本文件所在目录 workdir=os.path.abspath(os.path.dirname(__file__)) #文件存储目录 folder_storage=os.path.join(workdir,"files") baseurl="http://192.168.199.202:5000/download/" app = Flask(__name__,static_url_path='',root_path=workdir) api = Api(app) class music(Resource): def get(self): #templates文件夹下面 return render_template('index.html',) api.add_resource(Uploads, '/upload') api.add_resource(download, '/download/<string:file_name>') api.add_resource(rename_file, '/rename/<string:old_filename>/<string:new_filename>') api.add_resource(del_file, '/del/<string:filename>') api.add_resource(Four,'/four/<int:page>/<int:per_page>') api.add_resource(login,'/login') api.add_resource(music,'/music') @api.representation("text/html") def out_html(data,code,headers): return make_response(data) if __name__ == '__main__': app.run(host="0.0.0.0", port=5000) #app.run(debug=True)