访问带有Flask-Assets的URL时会出现以下错误,该URL应该呈现并缩小css。
DropDownListFor
以下是包含Flask-Assets
的代码ERROR 2016-09-01 02:45:00,096 app.py:1587] Exception on /SomeFile [GET]
Traceback (most recent call last):
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/vinay/App-Engine/zion-alpha/app/routes/home_routes.py", line 14, in show_file
return render_template('main.html')
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/templating.py", line 134, in render_template
context, ctx.app)
File "/Users/vinay/App-Engine/zion-alpha/lib/flask/templating.py", line 116, in _render
rv = template.render(context)
File "/Users/vinay/App-Engine/zion-alpha/lib/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/Users/vinay/App-Engine/zion-alpha/lib/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/vinay/App-Engine/zion-alpha/app/templates/main.html", line 6, in top-level template code
{% assets "css_all" %}
OSError: [Errno 78] Function not implemented
INFO 2016-09-01 02:45:00,116 module.py:788] default: "GET /SomeFile HTTP/1.1" 500 291
INFO 2016-09-01 02:45:00,853 module.py:402] [default] Detected file changes:
/Users/vinay/App-Engine/zion-alpha/app
HTML
def create_app():
"""Create the Flask App"""
app = Flask(__name__)
configure_blueprints(app)
css = Bundle('css/main.css',
'css/main2.css',
filters="cssmin",
output="static/css/min.css"
)
assets = Environment(app)
assets.register('css_all', css)
return app
文件夹结构
{% assets "css_all" %}
<link rel="stylesheet" href="{{ ASSET_URL }}"/>
{% endassets %}
4个目录,9个文件
答案 0 :(得分:0)
这似乎是flask-assets
和Google App Engine的问题,因为GAE不允许在运行时创建文件。
可能重复:GAE: Flask/webassets throws an expection on {% extends "base.html" %}
在部署到GAE之前缩小css,或者在运行时(不是首选)或构建时(首选)找到另一种服务缩小的css的方法。
一种可能性是在第一次运行(构建时)上创建缩小的js,然后可以将其上传到谷歌存储桶。
另一种选择是在运行时创建缩小的js并将其保存在memcache中。