I have simple aiohttp one-page web app and want to serve static files with aiohttp itself
app.router.add_static('/static/', os.path.join(root_path, 'static'))
But when accessing resource from browser I have an error Uncaught SyntaxError: Invalid or unexpected token
because index.js
file was served in some unexpected way.
Env: aiohttp==1.0.3
, Python 3.5.2
, Ubuntu 16.04.1 LTS
Was the file saved improperly or it's OS error or something wrong with aiohttp itself?
So the reason of the error was os sendfile
that was caching/serving files in some wrong way. export AIOHTTP_NOSENDFILE=1
solved an issue. Link with more details here . Of course, for production environment use nginx to serve your static files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.