5

I have a file test.css in a folder called css. I want to create url for this file. I know that I can use url_for like

url_for('static', filename="test.css")

to create url like static/test.css but I am not able to use like

url_for('css', filename="test.css")

to create the url that I am interested in css/test.css

How can I do this?

4

1 回答 1

7

static只是端点,请参阅routeview。因此,您可以创建自己的端点:

app.add_url_rule('/css/<path:filename>', endpoint='css',
                 view_func=app.send_static_file)
于 2013-08-15T13:33:09.097 回答