Helper module for Frozen-Flask based websites
Project description
elsa
Elsa will help you build your Frozen-Flask based website and deploy it to GitHub pages. It’s based on scripts from PyLadies.cz repo and is distributed under the terms of the MIT license, see LICENSE (does not apply for the image below). It requires Python 3.
Basic usage
Create you Flask app and give it to elsa.cli():
from flask import Flask
app = Flask(...)
# do stuff with app
if __name__ == '__main__':
from elsa import cli
cli(app, base_url='https://example.com')
This will add command line interface to the script, enabling you to use it like this:
python foo.py serve # serves the site, no freezing, so you can check it quickly
python foo.py freeze # freezes the site, i.e. makes a HTML snapshot
python foo.py deploy # deploys the frozen site to GitHub pages
See more options with --help.
Follow the quickstart tutorial for more information.
Travis CI based deployment
Travis CI is (in this context) a tool, that allows you to deploy the site automatically to GitHub pages after every push. All you have to do is tell Travis to run Elsa and provide a GitHub token. Elsa on Travis will freeze the site and deploy it frozen to GitHub pages. Elsa knows it’s being run on Travis and will use the provided GitHub token to gain push permissions. Elsa will push force to gh-pages branch in a single commit rewriting the history and all manual changes of that branch.
Here is an example .travis.yml file for automatic deployment. It assumes elsa and other requirements are in requirements.txt and that you are familiar with Travis CI (so it’s not very verbose):
language: python
python:
- '3.6'
script:
- 'python foo.py freeze'
env:
global:
- secure: "blahblah" # gem install travis; travis encrypt GITHUB_TOKEN=xyz --add
deploy:
provider: script
skip_cleanup: true
script: 'python foo.py deploy --no-freeze --push'
on:
branch: master
repo: only/yours
Testing
To run the test suite, install tox and run it:
tox
Elsa uses pytest, so if you are familiar with it, feel free to run it directly.
Further notes
URLs
When you use URLs without trailing slash (e.g. https://example.com/foobar), GitHub pages would serve the pages with bad Content-Type header (application/octet-stream instead of text/html) and the browser would attempt to download it. That’s why Elsa will not allow such thing and will treat MimetypeMismatchWarning from Frozen-Flask as error. Make sure to use URLs with trailing slash (e.g. https://example.com/foobar/) instead, so Frozen-Flask will create index.html in a folder and GitHub pages will use proper content type.
Changes
0.1.6
Add the --host option to CLI. It corresponds to flask run’s --host option.
When serving (with serve or freeze --serve), Elsa now listens on Flask’s default address, 127.0.0.1. The server is not visible externally. Use --host=0.0.0.0 to select the original, less secure behavior. (#67)
0.1.5
Add --verbose option for the CLI. If used, it prints all frozen URLs to standard error. Useful when freezing big projects on Travis CI. (#51)
0.1.4
Add invoke_cli option for the cli function. If set to False, it only returns the cli for further extending. (#45)
Don’t remove the remote tracking branch when --no-push is used (fixes #41)
Improve handling of FrozenFlaskWarning (#37)
Add the --show-git-push-stderr option to make deploy more verbose, this can help debug problems, but is potentially dangerous, hence the output of git push is hidden by default. (#37)
0.1.3
0.1.2
Security: Do not display the remote URL when pushing gh-pages branch. If you used Elsa 0.1 or 0.1.1 on Travis CI, revoke your GitHub token, it was probably leaked in the log. (#25)
0.1.1
Fix a problem with Travis CI based deployment
0.1
Add a test suite
Treat Frozen-Flask warnings as errors
Important: It is now recommended to run freeze in .travis.yml script section to catch problems in Pull Requests etc.
Important: This version of Elsa will warn if you use the deploy command without specifying --push or --no-push explicitly. In a future release, it will switch to not pushing the built pages by default.
Remove the dependency on sh to improve compatibility with Windows
Supports Linux, Mac OS X and Windows
The gh-branch is purged before the deploying commit (#14)
It is possible to shutdown the server via a special POST request (#21)
0.1.dev4
Set template auto_reload flag directly in serve mode (#8)
0.1.dev3
0.1.dev2
The CNAME route is now created automatically
0.1.dev1
Initial implementation from PyLadies.cz
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
Built Distribution
File details
Details for the file elsa-0.1.6.tar.gz
.
File metadata
- Download URL: elsa-0.1.6.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | caa4f03d1060c3ef960d25ad45d4548c6b937fe47aa3ff408f21fcd68dbe9db1 |
|
MD5 | bb2eea68c2147de8e35c2850a19f478e |
|
BLAKE2b-256 | 12ce392e1a35e28bc462fa6a25db1b90d72c5c518f5fc0851e99c3e83a97d418 |
File details
Details for the file elsa-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: elsa-0.1.6-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0cb4c504e12e9f9e00486aa48ea549ebc2b46d93a175758a62f5644f2562355 |
|
MD5 | 36d27bc371ff0b47f41a0fd97c809ab4 |
|
BLAKE2b-256 | cf910780ba35c0efea00c56b644121e52b8c23c6a0dd7a49dc0691b245b3b1ed |