TypeError: static_folder must be a string
TypeError: static_folder must be a string
$ python -c "from flask import Flask; app=Flask(__name__, static_folder=123)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: static_folder must be a string
Why this happens
static_folder config expects a filesystem path as a string. Passing integers or other objects raises TypeError. This often happens when reading configuration from environment without converting types.
Fix
Provide a proper string path or None to disable static. Use absolute or relative paths as strings.
Wrong code
from flask import Flask
app = Flask(__name__, static_folder=123)
Fixed code
from flask import Flask
app = Flask(__name__, static_folder="static")
Additional notes
- Blueprints also accept
static_folderstring. - Combine with
static_url_pathto customize URL. - Ensure the folder exists to avoid 404 when serving static files.