klen / flask-collect Goto Github PK
View Code? Open in Web Editor NEWCollect static files in flask application
Home Page: http://klen.github.com/Flask-Collect/
License: Other
Collect static files in flask application
Home Page: http://klen.github.com/Flask-Collect/
License: Other
In the very recent 2.0 release of Flask 2.0, they dropped support for Python < 3.6.
This includes the removal of the flask._compat
module (pallets/flask@662c245)
Thus, the following import won't work anymore: https://github.com/klen/Flask-Collect/blob/develop/flask_collect/collect.py#L7
We optimise our statics (using grunt/node) into a dist dir at build time. Seems Flask-Collect doesn't yet support configuring the source directory to use, instead always using spath = op.join(root, f)
. Is this lib the best approach to solve this? I may be able to submit the fix if so.
Cheers
It would be nice if Flask-Collect would detect if the COLLECT_STATIC_ROOT was not set to <APP.ROOT_PATH>/static and, if that is the case, also copy <APP.ROOT_PATH>/static to COLLECT_STATIC_ROOT.
Basically, when deploying to production, I want all my files in a non-standard location so Apache can serve them directly. If Flask-Collect would also copy files from /static, it would save me from having to do it manually.
I setup Collect
in my create_app
factory function but I don't have access to the Manager at that time. When I create the Manager
how do I add the collect command to it?
from myapp import create_app
manager = Manager(create_app)
manager.add_command('collect', ????)
Thanks.
The current source package and wheel on PyPI (version 1.3.2) contain a top-level "tests" package, which shouldn't be included.
It means that I can't do pkg_resources.resource_stream("tests", "path/to/fixture")
in my own tests
directory, as it instead picks up the installed package instead of the locally-importable tests
package.
Versions
Traceback (most recent call last):
File "manage.py", line 12, in <module>
from uiapp import app, models, db, manager
File "/Users/pavel/dev/my_proj/my_app/uiapp/__init__.py", line 22, in <module>
collect.init_script(manager)
File "/Users/pavel/.virtualenvs/my_proj/lib/python2.7/site-packages/flask_collect/collect.py", line 119, in init_script
manager.command(collect_proxy)
File "/Users/pavel/.virtualenvs/my_proj/lib/python2.7/site-packages/flask_script/__init__.py", line 285, in command
command = Command(func)
File "/Users/pavel/.virtualenvs/my_proj/lib/python2.7/site-packages/flask_script/commands.py", line 118, in __init__
args, varargs, keywords, defaults = inspect.getargspec(func)
File "/Users/pavel/.pyenv/versions/2.7.11/lib/python2.7/inspect.py", line 816, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <LocalProxy unbound> is not a Python function
As a workaround, I just added a call to static
. Seems to work well:
# manage.py
@manager.command
def collect():
"""Collect static from blueprints."""
return current_app.extensions['collect'].collect()
EDIT: commit 9979f22 may have caused this.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38240994-adding-manager-command-with-init_script-fails?utm_campaign=plugin&utm_content=tracker%2F394635&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394635&utm_medium=issues&utm_source=github).init_cli
method
Hello,
We are currently working with Invenio (https://github.com/inveniosoftware/invenio) a CERN, flask based application, that use Flask-Collect.
Invenio allows to add overlay with new design. Which means that we are collecting, first, static files from core, then from the different setuped overlays.
Unfortunately because the static files from the overlays have the same name, they are not replaced.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9698156-static-files-not-replaced-if-already-existing?utm_campaign=plugin&utm_content=tracker%2F394635&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394635&utm_medium=issues&utm_source=github).Hi
could it be possible to collect only static files for selected admin theme, not all?
or could you provide advice how to achieve that?
command flask collect
copies Flask-Admin static files to configured folder, but it should be different way
for example i have configured it like this:
COLLECT_STATIC_ROOT = 'var/www'
what i get is is whole copy of Flask-Admin static folder inside it,
..
vendor
vendor/leaflet
vendor/leaflet/images
vendor/select2
vendor/x-editable
vendor/x-editable/css
vendor/x-editable/img
vendor/x-editable/js
vendor/bootstrap-daterangepicker
admin
admin/css
admin/css/bootstrap3
admin/css/bootstrap2
admin/js
bootstrap
bootstrap/bootstrap3
bootstrap/bootstrap3/css
bootstrap/bootstrap3/js
bootstrap/bootstrap3/swatch
bootstrap/bootstrap3/swatch/darkly
bootstrap/bootstrap3/swatch/yeti
bootstrap/bootstrap3/swatch/paper
bootstrap/bootstrap3/swatch/cerulean
bootstrap/bootstrap3/swatch/default
bootstrap/bootstrap3/swatch/cyborg
bootstrap/bootstrap3/swatch/sandstone
bootstrap/bootstrap3/swatch/superhero
bootstrap/bootstrap3/swatch/fonts
bootstrap/bootstrap3/swatch/spacelab
bootstrap/bootstrap3/swatch/flatly
bootstrap/bootstrap3/swatch/lumen
bootstrap/bootstrap3/swatch/simplex
bootstrap/bootstrap3/swatch/united
bootstrap/bootstrap3/swatch/journal
bootstrap/bootstrap3/swatch/slate
bootstrap/bootstrap3/swatch/readable
bootstrap/bootstrap3/swatch/cosmo
bootstrap/bootstrap2
bootstrap/bootstrap2/css
bootstrap/bootstrap2/js
bootstrap/bootstrap2/swatch
bootstrap/bootstrap2/swatch/amelia
bootstrap/bootstrap2/swatch/img
bootstrap/bootstrap2/swatch/cerulean
bootstrap/bootstrap2/swatch/default
bootstrap/bootstrap2/swatch/cyborg
bootstrap/bootstrap2/swatch/superhero
bootstrap/bootstrap2/swatch/spacelab
bootstrap/bootstrap2/swatch/flatly
bootstrap/bootstrap2/swatch/simplex
bootstrap/bootstrap2/swatch/united
bootstrap/bootstrap2/swatch/journal
bootstrap/bootstrap2/swatch/slate
bootstrap/bootstrap2/swatch/spruce
bootstrap/bootstrap2/swatch/readable
bootstrap/bootstrap2/swatch/cosmo
but url pointing to admin theme is different
/admin/static/bootstrap/bootstrap3/swatch/cerulean/bootstrap.min.css
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.