JavaScript .js file content type default is text/javascript but could be application/javascript
niccokunzmann opened this issue · 1 comments
niccokunzmann commented
Replication: serve a static .js
file from a directory.
$ cat app.py
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route("/static/<path:path>")
def route_static(path):
"""/static/"""
return send_from_directory("static", path)
if __name__ == "__main__":
app.run(debug=True)
cat static/x.js
/*example*/
The behavior I get is
Content-Type
text/javascript; charset=utf-8
I would expect
Content-Type
application/javascript; charset=utf-8
See https://stackoverflow.com/a/189877/1320237
Environment:
- Python version: 3.11.6
- Flask version: 3.0.0
$ pip list
Package Version
------------ -------
blinker 1.7.0
click 8.1.7
Flask 3.0.0
itsdangerous 2.1.2
Jinja2 3.1.2
MarkupSafe 2.1.3
pip 23.2
setuptools 68.2.2
Werkzeug 3.0.1
wheel 0.41.2
davidism commented
You'll need to take that up with Python, we're using their mimetypes.guess_type
function.