This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| from base64 import b64decode | |
| from github import Github | |
| with open('access-token.txt') as token_file: | |
| token = token_file.read().strip() | |
| api = Github(token) | |
| site = api.get_repo('nottrobin/gh-cms-example-site') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| from base64 import b64decode | |
| from github import Github | |
| with open('access-token.txt') as token_file: | |
| token = token_file.read().strip() | |
| api = Github(token) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| with open('redirects.yaml') as redirects_file: | |
| redirects = json.load(redirects_file) | |
| new_redirects = {} | |
| for request, target in redirects.iteritems(): | |
| if '?' in request: | |
| # Remove anything with a question mark (it wont work) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| This will consume a 'redirects.txt' file containing redirects of the format: | |
| request/path http://example.com/target/path # some comment | |
| And output the same redirects in formatted JSON format instead: | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://clbin.com helper function | |
| # === | |
| # | |
| # Usage examples: | |
| # --- | |
| # | |
| # $ echo "hello world" | clbin | |
| # https://clbin.com/SwP5h | |
| # $ curl https://clbin.com/SwP5h | |
| # hello world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl -I http://cn.ubuntu.com/static/css/styles.css?v=d5d2934 | |
| ... | |
| Cache-Control: public, max-age=31557600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # myapp/settings.py | |
| WHITENOISE_MAX_AGE = 31557600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl -I localhost:8000/static/css/styles.css?v=d5d2934 | |
| ... | |
| Cache-Control: public, max-age=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # myapp/settings.py | |
| STATIC_ROOT = 'static' | |
| STATIC_URL = '/static/' | |
| # myapp/wsgi.py | |
| from django.core.wsgi import get_wsgi_application | |
| from whitenoise.django import DjangoWhiteNoise | |
| application = DjangoWhiteNoise(get_wsgi_application()) |