小编pet*_*urg的帖子

Flask dev服务器中静态文件的URL路由冲突

我想定义一个包含三个变量组件的url规则,例如:

@app.route('/<var_1>/<var_2>/<var3>/')
Run Code Online (Sandbox Code Playgroud)

但我发现开发服务器在尝试匹配静态文件之前会评估这些规则.所以像:

/static/images/img.jpg
Run Code Online (Sandbox Code Playgroud)

将被我的url规则捕获,而不是转发到内置的静态文件处理程序.有没有办法强制开发服务器首先匹配静态文件?

PS如果规则有两个以上的变量组件,这只是一个问题.

python werkzeug flask

7
推荐指数
2
解决办法
6251
查看次数

当我指定文件时,"docker-compose build"会向我显示帮助文本

在构建期间指定撰写文件时:

docker-compose build -f compose-production.yml

图像不会构建,而是显示帮助文本:

$ docker-compose build -f compose-production.yml 
Build or rebuild services.

Services are built once and then tagged as `project_service`,
e.g. `composetest_db`. If you change a service's `Dockerfile` or the
contents of its build directory, you can run `docker-compose build` to rebuild it.

Usage: build [options] [SERVICE...]

Options:
    --force-rm  Always remove intermediate containers.
    --no-cache  Do not use cache when building the image.
    --pull      Always attempt to pull a newer version of the image.
Run Code Online (Sandbox Code Playgroud)

谁知道发生了什么?

yaml docker docker-compose

2
推荐指数
1
解决办法
1309
查看次数

使用Flask-Security作为REST API的一部分

该烧瓶安全文档提到的所有重要观点端点的JSON/Ajax支持.因此,通过使用JSON对象命中视图,可以获得所有buts-in Flask-Security非常棒的功能.

但是,现在我正在尝试将其用作RESTful API的一部分,并且它不起作用,因为它需要一个CSRF令牌,这对于网页是必需的,但对于API则不需要:

{
    "meta": {
        "code": 400
    },
    "response": {
        "errors": {
            "csrf_token": [
                "CSRF token missing"
            ]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

解决这个问题的最佳方法是什么?

rest flask wtforms flask-security

1
推荐指数
1
解决办法
1823
查看次数

在 Flask-Admin 中修改输入字段大小

有谁知道在 Flask-Admin 中指定输入字段大小的简单方法?

例如class="input-xlarge",在输入字段上设置可以解决问题,但是 Flask-Admin 有没有一种简单的方法可以做到这一点?

css python flask twitter-bootstrap flask-admin

0
推荐指数
1
解决办法
1555
查看次数