librelist archives

« back to archive

Change static_folder From Configuration File

Change static_folder From Configuration File

From:
Ji Zhang
Date:
2012-10-05 @ 10:25
Hi,

I can change the static_folder when I create the app, like:

app = Flask(__name__, static_folder='static-built')

But what if I wanna get it done in a configuration file?

# config.py
STATIC_FOLDER = 'static-built'

# __init__.py
app = Flask(__name__)
app.config.from_object('foo.config')

Thanks.

Re: [flask] Change static_folder From Configuration File

From:
Simon Sapin
Date:
2012-10-05 @ 12:04
Le 05/10/2012 12:25, Ji Zhang a écrit :
> Hi,
>
> I can change the static_folder when I create the app, like:
>
> app = Flask(__name__, static_folder='static-built')
>
> But what if I wanna get it done in a configuration file?
>
> # config.py
> STATIC_FOLDER = 'static-built'
>
> # __init__.py
> app = Flask(__name__)
> app.config.from_object('foo.config')

Hi,

This could be done by overriding the static_folder property in a 
subclass. I wrote a code example in a snippet:

http://flask.pocoo.org/snippets/102/

Cheers,
-- 
Simon Sapin