I am developing a web app in app engine python, I cant find GET /favicon.ico in console when I execute it in chrome or IE. Whereas there is no issue with firefox or safari, my favicon.ico is displayed in it.
here is my handlers in app.yaml:
handlers:
- url: /favicon.ico
static_files: favicon.ico
upload: favicon.ico
- url: /sitemap.xml
static_files: sitemap.xml
upload: sitemap.xml
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /static
static_dir: static
- url: .*
script: main.app
There is no 404 error for favicon, /facivon.ico not getting executed in chrome , IE.
You could try
- url: /favicon\.ico
mime_type: image/vnd.microsoft.icon
static_files: static/favicon.ico
upload: static/favicon.ico
Related
I am trying to make a basic application that would make my index.html file run offline - when no internet is available. I am using Google App Engine, Webapp2 and Jinja2. Would you suggest a better framework for an offline website / webapp.
When I run this application I get this console error:
Creating Application Cache with manifest http://localhost:9080/static/cache.manifest localhost/:1
Application Cache Checking event localhost/:1
Application Cache Downloading event localhost/:1
Application Cache Progress event (0 of 1) http://localhost:9080/index.html localhost/:1
Application Cache Error event: Resource fetch failed (404) http://localhost:9080/index.html
I used the following:
Files
static/cache.manifest
main.py
index.html
app.yaml
main.py
import os, webapp2, jinja2
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
class Home(webapp2.RequestHandler):
def get(self):
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render())
app = webapp2.WSGIApplication([('/', Home),
], debug=True)
index.html
<!DOCTYPE html>
<html manifest="/static/cache.manifest">
<head>
</head>
<body>
Hello World
</body>
</html>
cache.manifest
CACHE MANIFEST
/index.html
app.yaml
application: formetoteston
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static/(.*\.(appcache|manifest))
mime_type: text/cache-manifest
static_files: static/\1
upload: /static/(.*\.(appcache|manifest))
expiration: "0m"
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: "2.6"
I found it! I needed to add the proper URL handlers in app.yaml. Except I moved my index.html to /static.
application: formetoteston
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: static/(cache.manifest)
mime_type: text/cache-manifest
static_files: static/cache.manifest
upload: static/(cache.manifest)
- url: static/(.*)
static_files: static/index.html
upload: static/index.html
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: "2.6"
i have a problem to use image with static folder path in my page.
this is my app.yaml
application: something
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /images
static_dir: static/images
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
I have templates, static/images, controllers (has MainHandler.py) folders and in my root i have main.py and app.yaml files. in my templeate folder i have index.html file that contain:
<div>
<img src="images/fig1.jpg">
</div>
my problem is when page was loaded i cant see my fig1.jpg picture.
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.
I'm using the following yaml configuration:
application: xxxxxxxx
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /bootstrap
static_dir: static/bootstrap
- url: /fonts
static_dir: static/fonts
- url: /js
static_dir: static/js
- url: /images
static_dir: static/images
- url: /css
static_dir: static/css
- url: /favicon\.ico
static_files: ./static/favicon.ico
upload: ./static/favicon\.ico
- url: /.*
script: main.app
libraries:
- name: django
version: "1.3"
And my folder structure is like this:
\
....static
..........bootstrap
...................css
...................js
...................img
..........css
..........fonts
..........images
..........js
In the development environment it works fine (using latest version available), but when I deploy the app it doesn't. I know the filenames are case sensitive on gae, but I've already checked that.
What else can be wrong?
Please Help.
Thanks
As stupid it may seems but removing the project from GAE Launcher and adding it back again and re-deploy it solved the issue.
When I add the secure: always parameter in app.yaml, I am still not redirected to a https. Https works when I type it in manually, and I'm testing this on the live server, but it treats the website as though secure: always isn't there.
I eventually just tried to map it to all the handlers in the yaml file, but it still has no effect.
application: appname
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
secure: always
- url: /css
static_dir: css
secure: always
- url: /fonts
static_dir: fonts
secure: always
- url: /js
static_dir: js
secure: always
- url: /img
static_dir: img
secure: always
- url: .*
script: main.app
secure: always
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: "2.6"
error_handlers:
- file: default_error.html
I am using flask and the python 2.7 GAE SDK. I am trying to include an interactive shell, in my app.
I am trying to include the following interactive python shell in my app, so that I can interact with the GAE API while development - http://code.google.com/p/google-app-engine-samples/source/browse/trunk/shell/
As instructed I have copied the static/ and templates/ folders, and shell.py to the root of my app.
I have also added the url route ONLY to my app.yaml (shell)-
application: myflaskonappengineapp
version: 1
runtime: python27
api_version: 1
threadsafe: false
default_expiration: "5d"
builtins:
- appstats: on
- admin_redirect: on
- deferred: on
- remote_api: on
libraries:
- name: jinja2
version: "2.6"
- name: markupsafe
version: "0.15"
- name: lxml
version: "2.3"
- name: numpy
version: "1.6.1"
- name: PIL
version: "1.1.7"
- name: pycrypto
version: "2.3"
- name: setuptools
version: "0.6c11"
- name: webapp2
version: "2.3"
- name: webob
version: "1.1.1"
- name: yaml
version: "3.10"
inbound_services:
- warmup
handlers:
- url: /favicon.ico
static_files: application/static/img/favicon.ico
upload: application/static/img/favicon.ico
- url: /robots.txt
static_files: application/static/robots.txt
upload: application/static/robots.txt
- url: /_gae_mini_profiler/static
static_dir: packages/flaskext/gae_mini_profiler/static
- url: /static
static_dir: application/static
#interactive shell
- url: /shell
script: shell.py
- url: /remote_api
script: /opt/google_appengine/google/appengine/ext/remote_api/handler.py
- url: .*
script: application.app
However when I try to access the url /shell, I get a 404 error ? Do I need to configure flask also for routing ? Why is flask handling this url instead of shell.py?
You need to modify the shell.py to handle the URL '/shell' as well as app.yaml.
In particular, you need to edit the line 303 of the shell.py.
from
[('/', FrontPageHandler),
to
[('/shell', FrontPageHandler),
You also need to update your app.yaml like(add wildcard):
- url: /shell.*
script: shell.py
Please consider adding login:admin to the shell handler, otherwise you will open up the shell capability to everyone in the world.