Utilities for working with pakk files in a flask web application.
Project description
pakk flask
Utilities for working with pakk files in a flask web application.
Getting Started
Install pakk and pakk_flask:
$ python3 -m pip install pakk pakk_flask
Then you can use pakk_flask to send pakked assets as static files in a flask web application:
from pakk_flask import send_from_directory
@APP.route("/static/<path:path>")
def get_static_file(path):
with open("./files.pakk", "rb") as in_file:
unpakked = unpakk(KEY, in_file)
if unpakked.has_blob(path):
return send_from_directory(unpakked, path)
else:
return send_from_directory("./static", path)
You can also use pakk_flask to render templates from pakk files:
from pakk_flask import render_template, PakkTemplate
@APP.route("/home")
def get_home_page():
with open("./files.pakk", "rb") as in_file:
unpakked = unpakk(KEY, in_file)
render_template(PakkTemplate(unpakked, "index.html"),
some_value="Hello, ",
another_value="World!")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pakk_flask-1.1.0.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for pakk_flask-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32a528850bddda3aaab2ecb3c802dd1a52b27960c87e032312e5326d5456d7e3 |
|
MD5 | 6c9d31284930b53e4c0cf98f8c74c6ad |
|
BLAKE2b-256 | 09c4ada06a9bb7d512e7482833a91e2d2888276338123ba22c9491d92c143af7 |