Gramex 1.79 supports multiple default filenames, relative opens in templates, and distributed OTP.
FileHandler supports multiple default filenames.
When FileHandler points to a directory, you could specify a default file, e.g. index.html like this:
url:
default-filehandler:
pattern: /dir/
handler: FileHandler
kwargs:
path: dir/
default_filename: index.html
If index.html is missing, it serves a directory listing or reports an error.
But if the default filename may vary, e.g. some folders use a README.md and some use an index.html, you can specify a sequence of fallbacks like this:
url:
default-filehandler:
pattern: /dir/
handler: FileHandler
kwargs:
path: dir/
default_filename:
- default.template.html # Serve this as a template, if it exists
- index.html # Else serve this as HTML
- README.md # Else serve this as Markdown to HTML
In a Python script, gramex.cache.open('data.json', rel=True) reads
data.json relative to the Python script, i.e. from the same folder where the Python script is.
But in a template, gramex.cache.open('data.json', rel=True) used to read
data.json relative to where Gramex was run from.
This is now fixed. For example, if an index.template.html has this code:
{% set data = gramex.cache.open('data.json', rel=True) %}
… it reads data.json from the same folder where index.template.html is.
By default, OTPs and API keys are stored locally in a SQLite database.
If you load-balance a Gramex app across multiple servers, the OTPs and API keys created on one server won’t be shared with the other servers.
To share the keys, add an otp: service to gramex.yaml that points to a shared database:
otp:
url: mysql+pymysql://root@server/db
table: otp
The url can point to any FormHandler compatible database.
The table can be any new table name. Gramex tries to create it with the following columns. You
can point to any existing table with these columns too:
user: TEXTemail: TEXTtoken: TEXTexpire: REALGramex 1.79 is backward compatible with previous releases unless the release notes say otherwise. Automated builds test this.
Every Gramex release is tested for security vulnerabilities using the following tools.
The Gramex code base has: