Faouzi FJTech
Faouzi FJTech

Reputation: 1071

how to serve static files on google app engine

Basically I'm new to the google app engine, I have a folder called templates in which I have several files :

index.php
result.php
request.php

However on the yaml.app I figured out only how to run the server locally by making the templates/index.php default page. I mean when I go to http://localhost:8080 it is what I see. But when I do http://localhost:8080/templates/index.php it says 404 not found. How Can I use all the files I want in any directory inside my app, is it somekind of rule I should add to my app.yaml?

Here is the current app.yaml im using :

application: sympy-live-hrd
version: 38

runtime: python27
threadsafe: true
api_version: 1

libraries:
- name: numpy
  version: latest
- name: matplotlib
  version: latest

handlers:
- url: /static
  static_dir: static
  expiration: 1d

# cache-busting scheme
# request /static-(app version)/filename
- url: /static-[0-9]+/(.*)
  static_files: static/\1
  upload: static/(.*)

# if you're adding the shell to your own app, change this regex url to the URL
# endpoint where you want the shell to run, e.g. /shell . You'll also probably
# want to add login: admin to restrict to admins only.
- url: .*
  script: shell.application

The Shell.application is a python script that I edited to use templates/index.php as default

Upvotes: 0

Views: 1223

Answers (1)

dragonx
dragonx

Reputation: 15143

I'm assuming index.php is a script?

I believe you have to run php scripts using the php runtime. They won't run as scripts from the python runtime, so firstly, you won't be able to run the php scripts.

Second, you need a handler that will point to your templates folder, but that doesn't exist.

handlers:
- url: /templates
  static_dir: templates
  expiration: 1d

Note that this will just load the file, it won't run php files unless you're using the php runtime.

Upvotes: 2

Related Questions