Google App Engine: Won't serve static assets with below error:
Started a bug in the issue tracker for GAE. See here: https://code.google.com/p/googleappengine/issues/detail?id=11001
In the meantime, the temporary patch in comme #4 on that thread works.
google\appengine\tools\devappserver2\static_files_handler.py
line 166, 167, 168, need add str to self._get_mime_type(full_path)
if user_headers.Get('Content-type') is None:
#headers.append(('Content-type', self._get_mime_type(full_path)))<br />
headers.append(('Content-type', str(self._get_mime_type(full_path))))<br /><br />
# 2014-06-09 fix on Win7 "TypeError: WSGI response header value u'text/html' is not of type str"
Google App Engine add image to page with static folder
What is the url of this page? If it looks like a subdirectory, then your using a relative path for your image is not pointing to the images
path. Try changing to:
<div>
<img src="/images/fig1.jpg">
</div>
If using Windows, there is a known bug. See:
Google App Engine: Won't serve static assets with below error:
Try adding mime_type: "image/jpeg"
to your image handler, to see if that is the cause.
App Engine GO SDK Load CSS file with 500 error
There is a bug in the app.yaml static handlers for Windows:
Google App Engine: Won't serve static assets with below error:
Serving static HTML with Google App Engine and bottle
To serve static files in App Engine, it's by far most efficient (faster for your users, and less expensive for you if you pass the free daily quota) to do so directly from app.yaml
-- just add
- url: /
static_files: static/index.html
to app.yaml
before the "catch-all" url: /.*
directive.
This way, your app won't be queueing up that static file request behind others that might be waiting, nor ever need to spin up and warm up a new instance, nor run any of your code -- it will just serve the static file to the the user pronto, just as fast as Google knows how to (including caching and CDN-like speed-ups "behind the curtains" as/if applicable).
There's really no reason to serve up static files from code, when you can instead so easily leverage Google's own serving infrastructure!
Can not serve static content files
This isn't your fault -- it's a bug in App Engine: https://code.google.com/p/googleappengine/issues/detail?id=11001
There's a thread with some workarounds here: Google App Engine: Won't serve static assets with below error:
Google App Engine service with static files
The problem is that the path you're requesting is actually /dist/main.js
, which doesn't match the apple
service dispatch rule pattern: */apple/*
- so it gets routed to the default
service.
To fix it you need to:
update the patterns in the
apple.yaml
file (which BTW you should callapple
to match your dispatch service name):# apple.yaml
service: apple
handlers:
- url: /apple/dist/(.+)
static_files: dist/\1
upload: dist/(.+)
- url: /.*
static_files: dist/index.html
upload: dist/index.htmlNote that even if the last rule above can match anything it won't actually get requests without an
*/apple/*
in the path because those won't make it to theapple
service.refer to the files using the updated paths, so that the dispatcher can route them to the
apple
service:<script type="text/javascript" src="/apple/dist/main.js"></script>
App Engine: Static Files Not Updating on Deploy
When performing changes in static files in an App Engine application, changes will not be available immediately, due to cache, as you already imagined. The cache in Google Cloud cannot be manually flushed, so instead I would recommend you to change the expiration time to a shorter period (by default it is 10 minutes) if you want to test how it works, and later setting an appropriate expiration time according to your requirements.
Bear in mind that you can change the static cache expiration time both for all static files or for just the ones you choose, just by setting the proper element in the app.yaml file.
Related Topics
Why Does Range(Start, End) Not Include End
Get Mouse Deltas Using Python! (In Linux)
How to Create a User in Linux Using Python
Automatic Detection of Display Availability with Matplotlib
Making Python Script Accessible System Wide
A Simple Python Deployment Problem - a Whole World of Pain
Pairing Bluetooth Devices with Passkey/Password in Python - Rfcomm (Linux)
Determine If Package Installed with Yum Python API
Scrapy: Couldn't Bind: 24: Too Many Open Files
Groupby Pandas Dataframe and Select Most Common Value
How to Get Hard Disk Serial Number Using Python
Find the Oldest File (Recursively) in a Directory
Cat, Grep and Cut - Translated to Python
What's the Advantage of Queues Over Pipes When Communicating Between Processes