zoukankan      html  css  js  c++  java
  • 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)

  • 相关阅读:
    雪花降落CADisplayLink
    图片分离--分成两片
    判断是否输入表情符号
    字符串过滤
    UICollectionView Layout自定义 Layout布局
    本地化 NSLocal
    CAAnimation动画--(旋转/缩放/移动/闪烁)
    摇一摇
    监听键盘升降
    ❄️ 雪花降落
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14176361.html
Copyright © 2011-2022 走看看