fresco-fs: filesystem resources for the fresco framework
fresco-fs provides a flexible framework to load and serve content from a filesystem directory, integrated with the fresco web framework.
This package was developed for the Skot.be kot listings site, where it is used to serve some of the site’s static content.
Example:
from fresco import FrescoApp
from fresco_fs import FSResources
import markdown
def serve_markdown(path):
""" Take a path to a .md file and turn it into an HTML response """
with open(path, 'r', encoding='utf-8') as f:
return Response(markdown.markdown(f.read()))
pages = FSResources(
search_path=['path/to/content/files/'],
# Each of extension will be added to the request filename in
# turn until one matches. So a request for '/mypage' would try
# '/mypage.md' then '/mypage.txt'.
# (Note that a request for '/mypage.txt' would be translated into
# '/mypage.txt.md' and '/mypage.txt.txt'.)
search_extensions=['.md', '.txt'],
# A function taking a mapped path and returning a fresco Response.
responder=serve_markdown,
# The route name to use. Routes can be generated with
# `urlfor('pages', path='mypage')`
route_name='pages')
app = FrescoApp()
app.include('/', pages)
FSResources allows paths to be rewritten on ingress by passing a rewriter function to the constructor. This function must take the requested path and return zero or more rewritten paths. Each rewritten path is then tested in order, and the first existing path is served.
For example to serve different content depending on language, you could write a function like this:
def try_i18n_paths(virtualpath):
lang = get_active_language()
return ['{}.{}'.format(virtualpath, lang), virtualpath]
The FSResources constructor would then look like this:
pages = FSResources(
search_path=['path/to/content/files/'],
search_extensions=['.md', '.txt'],
responder=serve_markdown,
rewriter=try_i18n_paths)
0.1 (released 2017-03-06)
Initial release
Metadata
Release files for fresco-fs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fresco-fs-0.1.1.tar.gz | 7.3 kB | Without provenance | Details for fresco-fs-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fresco_fs-0.1.1-py2-none-any.whl | Python 2 | none | any | Details for fresco_fs-0.1.1-py2-none-any.whl |
Total release size: 12.6 kB
Release files / fresco-fs-0.1.1.tar.gz
| Download URL | fresco-fs-0.1.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bd6f2dd356f024aee68c34a0818e533ca76803c187f431944938d960f3119ef
|
|
BLAKE2b-256 checksum How to use checksums |
66e6d7a46213f579fa62a38b0e27ad049f8e5b65c55f6010f4f1eae57e24ce3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / fresco_fs-0.1.1-py2-none-any.whl
| Download URL | fresco_fs-0.1.1-py2-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
432d2fa0a1d1dc9058cbeb0960a5059539e263c0434c7b6618376525877cab7b
|
|
BLAKE2b-256 checksum How to use checksums |
c721ac1f23136ba17e576d50749646db647ea43192ce5ca51b48476ebcc33f67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for fresco-fs 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.