Skip to content

Commit 3a17066

Browse files
committed
Initial commit.
0 parents  commit 3a17066

29 files changed

+734
-0
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
custom: ['https://www.buymeacoffee.com/hackersslackers']

.github/flask-assets@2x.jpg

508 KB
Loading

.gitignore

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
downloads/
14+
eggs/
15+
.eggs/
16+
lib/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
MANIFEST
26+
dist/
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a static
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# DS Store
107+
.DS_Store
108+
109+
# idea
110+
.idea

Pipfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
Lesscpy = "*"
8+
CSSMin = "*"
9+
JSMin = "*"
10+
11+
[packages]
12+
Flask = "*"
13+
Flask-Assets = "*"
14+
Python-Dotenv = "*"
15+
16+
[requires]
17+
python_version = "3.8"

Pipfile.lock

Lines changed: 155 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Flask-Assets Tutorial
2+
3+
![Python](https://img.shields.io/badge/Python-v3.8-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4+
![Flask](https://img.shields.io/badge/Flask-v1.1.1-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
5+
![Flask-Assets](https://img.shields.io/badge/Flask--Assets-v2.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6+
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
7+
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/flask-assets-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-assets-tutorial/issues)
8+
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/flask-assets-tutorial.svg?style=flat-square8&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-assets-tutorial/stargazers)
9+
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/flask-assets-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-assets-tutorial/network)
10+
11+
![Flask Assets Tutorial](https://github.com/hackersandslackers/flask-assets-tutorial/.github/flask-assets@2x.jpg)
12+
13+
Structure your Flask apps in a scalable and intelligent way using Blueprints. This repository contains source code for the accompanying tutorial on Hackers and Slackers: https://hackersandslackers.com/flask-blueprints/
14+
15+
## Getting Started
16+
17+
Installation is recommended with Pipenv:
18+
19+
```shell
20+
$ git clone https://github.com/hackersandslackers/flask-assets-tutorial.git
21+
$ cd flask-assets-tutorial
22+
$ pipenv shell
23+
$ pipenv update
24+
$ pip install lesscpy cssmin jsmin
25+
$ python3 main.py
26+
```
27+
28+
Alternatively, try installing via **setup.py**:
29+
30+
```shell
31+
$ git clone https://github.com/hackersandslackers/flask-assets-tutorial.git
32+
$ cd flask-assets-tutorial
33+
$ python3 setup.py install
34+
$ pip install lesscpy cssmin jsmin
35+
$ python3 main.py
36+
```
37+
-----
38+
39+
**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content.
40+

config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Flask configuration variables."""
2+
from os import environ
3+
from dotenv import load_dotenv
4+
5+
6+
load_dotenv()
7+
8+
9+
class Config:
10+
11+
# General
12+
FLASK_ENV = environ.get('FLASK_ENV')
13+
FLASK_DEBUG = 'wsgi.py'
14+
STATIC_FOLDER = 'static'
15+
TEMPLATES_FOLDER = 'templates'
16+
17+
# Flask-Assets
18+
LESS_BIN = '/usr/local/bin/lessc'
19+
ASSETS_DEBUG = False
20+
ASSETS_AUTO_BUILD = True
21+

flask_assets_tutorial/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Initialize app."""
2+
from flask import Flask
3+
from flask_assets import Environment
4+
from .assets import compile_assets
5+
6+
assets = Environment()
7+
8+
9+
def create_app():
10+
"""Construct the core flask_assets_tutorial."""
11+
app = Flask(__name__, instance_relative_config=False)
12+
app.config.from_object('config.Config')
13+
14+
# Initialize plugins
15+
assets.init_app(app)
16+
17+
with app.app_context():
18+
# Import parts of our flask_assets_tutorial
19+
from .admin import admin_routes
20+
from .main import main_routes
21+
app.register_blueprint(admin_routes.admin_bp)
22+
app.register_blueprint(main_routes.main_bp)
23+
compile_assets(assets)
24+
25+
return app
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Routes for logged-in account pages."""
2+
from flask import Blueprint, render_template
3+
4+
5+
admin_bp = Blueprint('admin_bp', __name__, template_folder='templates', static_folder='static') # Blueprint Configuration
6+
7+
8+
@admin_bp.route('/dashboard', methods=['GET'])
9+
def dashboard():
10+
"""Admin dashboard route."""
11+
return render_template('dashboard.jinja2',
12+
title='Admin Dashboard | Flask-Blueprint Tutorial',
13+
template='dashboard-static account',
14+
body="Account")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
p {
2+
width: 100%
3+
}

0 commit comments

Comments
 (0)