用于在flask web应用程序中处理pakk文件的实用程序。
pakk-flask的Python项目详细描述
帕克烧瓶
用于在flask web应用程序中处理pakk文件的实用程序。
开始
安装PAKK和PAKK U烧瓶:
$ python3 -m pip install pakk pakk_flask
然后,您可以使用pakk_flask在flask web应用程序中将已打包的资产作为静态文件发送:
frompakk_flaskimportsend_from_directory@APP.route("/static/<path:path>")defget_static_file(path):withopen("./files.pakk","rb")asin_file:unpakked=unpakk(KEY,in_file)ifunpakked.has_blob(path):returnsend_from_directory(unpakked,path)else:returnsend_from_directory("./static",path)
您还可以使用pakk_flask渲染来自pakk文件的模板:
frompakk_flaskimportrender_template,PakkTemplate@APP.route("/home")defget_home_page():withopen("./files.pakk","rb")asin_file:unpakked=unpakk(KEY,in_file)render_template(PakkTemplate(unpakked,"index.html"),some_value="Hello, ",another_value="World!")