I have a project directory and a sub directory set up as such:
/proj_dir
/proj_dir/audio
app.yaml:
handlers:
- url: /.*
script: main.py
- url: /audio
static_dir: audio
main.py is a simple Python program that, on a GET request, outputs the "index.html" file also in the proj_dir directory. The index.html file contains some javascript code that plays the audio file.
The problem is that index.html plays the audio file without issue when run locally. Once deployed, however, I get a 404 when trying to retrieve the audio:
INFO 2010-11-13 20:43:10,046 dev_appserver.py:3283] "GET /audio/bangagong.mp3 HTTP/1.1" 404 -
Any help appreciated. Thanks.
You need to change the order of your url handlers. The * handler captures everything. Try this instead:
handlers:
- url: /audio
static_dir: audio
- url: /.*
script: main.py
Related
I was trying to use google app engine cloud space. My program is running without any problem in localhost, but when I tries to host it in google app engine, static files are not served. The app.yaml is as follows:
application: myTestApp-nn34322
version: 1
runtime: go
threadsafe: true
api_version: go1
handlers:
- url: /static/css
static_dir: ../static/css
mime_type: "text/css"
- url: /static/js
static_dir: ../static/js
mime_type: "text/javascript"
- url: /static/images
static_dir: ../static/images
- url: /.*
script: _go_app
You should put every static resources under the same folder where you put your app.yaml file, else they won't get uploaded to AppEngine.
So you should put your static folder next to app.yaml, and then of course the correct path is simply static/xxx, e.g.:
- url: /static/css
static_dir: static/css
mime_type: "text/css"
- url: /static/js
static_dir: static/js
mime_type: "text/javascript"
- url: /static/images
static_dir: static/images
Note:
If you intend to use these static files from your Go app too (e.g. you want to read their content), that requires special handling because resources matched by static file patterns will not be copied to the application after uploading (static files are served by separate servers). For details, see Google App Engine Golang no such file or directory. Basically you either have to duplicate the static files, or provide the application_readable option to the static file handler.
I have a ready php website. For that website I am writing app.yaml for google app engine.
I read so many answers but it doesnt help me.
I am facing problem with php files under various subfolders in libraries folder.
In index.php, i accept rss feed url and process it for full text feed by calling other php files. but getting this error.
/makefulltextfeed.php?url=https%3A%2F%2Fnews.google.co.in%2Fnews%3Fpz%max
=10&links=preserve&exc=&submit=Create+Feed was not found on this server.
How to write app.yaml for all php files which comes under various sub-folders??
Do i have to write handlers: for all individual php files??
I am stuck here for whole day.
I am new to this topic. So if you find this as stupid question please forgive me.
Here is my app.yaml
application: xxxx-xxxx-90212
version: alpha-001
runtime: php
api_version: 1
handlers:
- url: /
script: index.php
- url: /config
script: config.php
- url: /makefulltextfeed
script: makefulltextfeed.php
- url: /css
static_dir: css
- url: /js
static_dir: css
- url: /images
static_dir: images
I have php files in subfolder. How to write app.yaml for that.
As described here you can use this notation to match all root path, that ends with .php, to a php script
# Serve php scripts.
- url: /(.+\.php)$
script: \1
This config assume that each your URL ends with .php, you can modify url regex to catch all urls (I test only the regex but I think it's works :) )
# Serve ALL php scripts.
- url: /((.+\/).*)$
script: \1.php
Or you can simulate httpd mod_rewrite as described here.
I’m new to google app engine and I’m trying to configure my app.yaml file for a web application which utilizes php and ajax. I’ve got the application running in the PHP SDK using the following yaml file:
application: foobar
version: 1
runtime: php
api_version: 1
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /
script: index.php
- url: /ajax.php
script: ajax.php
- url: /index.*
script: index.php
- url: /about.*
script: about.php
- url: /terms.*
script: terms.php
- url: /contact.*
script: contact.php
- url: /update.*
script: update.php
login: required
secure: always
- url: /login.*
script: login.php
login: required
secure: always
- url: /.*
script: index.php
Although this is fundamentally working I’ve got a feeling I’m doing something wrong because I don’t really want to provide access to ajax.php since it is purely for ajax processing. When I type ‘ajax.php’ into the browser in IE9 I’m prompted to open or save ‘ajax.js’, which contains processing code from the ajax file. In other browsers the same code is dumped directly onto the webpage.
How can I allow ‘ajax.php’ file to be accessed by ‘index.php’ but avoid this issue?
I'm practically new to Google App Engine, but i have a homework to create some app with it.
I'm trying to debugging my app offline using google interactive shell. http://localhost:8080 looks fine, but when i tried to open http://localhost:8080/shell for debugging, it gave me broken URL. I have my directories checked, and they are fine for me.
I think my problem is in app.yaml file. Well, I know nothing about .yaml file, could anyone please tell me where I put something wrong in it?
Here's my app.yaml (I put all interactive shell properties in folder named 'shell')
application: myapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /static
static_dir: shell/static
expiration: 1d
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
- url: /shell.*
script: shell/shell.py
- url: /
script: myapp.py
Should the shell.* be shell in yaml rule if you want to find it in http://localhost:8080/shell
- url: /shell
script: shell/shell.py
I am trying to develop on Google App Engine and in the list of the errors displayed in the admin console I always see the following:
/favicon.ico
i read the documentation , added a new folder called static and added this in my app.yaml:
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
but even now I'm getting the same error...
This entry should be placed before the entry for the main handler, like:
- url: /favicon.ico
static_files: media/img/favicon.ico
upload: media/img/favicon.ico
- url: /robots.txt
static_files: media/robots.txt
upload: media/robots.txt
- url: .*
script: main.py
The entries are processed in order of apperance and first one that matches wins.
If you are doing this in Java, I got rid of the error by putting a blank "favicon.ico" file in the "war" directory.
If you want to make your own quick and ugly "favicon.ico" file, this website was super easy to use: http://www.favicon.cc/
For your application, favicon.ico should be a static image. You can upload a favicon.ico file with your application, and in your app.yaml file configure your application to serve the image when the url /favicon.ico is requested. Below is an example entry in your app.yaml file for /favicon.ico. We assume you include the favicon.ico file in the directory path static/images:
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
is written here
I am using this snippet in a GAE app configuration:
handlers:
- url: /(.*\.(ico|png|webmanifest))$
static_files: faviconfiles/\1
upload: faviconfiles/.*\.(ico|png|webmanifest)$
I then put the corresponding set of files (these days if you seriously want to set a "favicon" it's a set of files incl. e.g. apple-touch-icon.png) into the ./faviconfiles directory next to my app.yaml.