Skip to content

Instantly share code, notes, and snippets.

@ashb
Created September 2, 2019 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashb/7be22f075e569de76f6e4a553cbb1b1e to your computer and use it in GitHub Desktop.
Save ashb/7be22f075e569de76f6e4a553cbb1b1e to your computer and use it in GitHub Desktop.
Serving custom static files form Airflow Plugin
from flask import Blueprint
import os
"""
Create this file as ./plugins/staticfiles.py in your ARIFLOW_HOME directory
It will serve all files under ./static/ available under /a/static/ (The "a" comes from the ``url_prefix`` argument.)
"""
bp = Blueprint(
"test_plugin", __name__,
url_prefix="/a",
static_folder=os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'static')),
static_url_path='/static')
class StaticPlugin(AirflowPlugin):
name = "themes"
flask_blueprints = [bp]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment