如何在谷歌应用引擎上提供静态文件


how to serve static files on google app engine

基本上我是谷歌应用程序引擎的新手,我有一个名为templates的文件夹,其中有几个文件:

index.php
result.php
request.php

然而,在yaml.app上,我只知道如何通过使templates/index.php成为默认页面来在本地运行服务器。我的意思是,当我去http://localhost:8080时,我看到的就是它。但当我做http://localhost:8080/templates/index.php时,它说404没有找到。我如何在应用程序的任何目录中使用我想要的所有文件,这是我应该添加到app.yaml中的某种规则吗?

这是当前的app.yaml-im使用:

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

Shell.application是一个python脚本,我编辑它以使用templates/index.php作为默认

我假设index.php是一个脚本?

我认为您必须使用php运行时来运行php脚本。它们不会作为python运行时的脚本运行,因此首先,您将无法运行php脚本。

其次,您需要一个指向templates文件夹的处理程序,但该处理程序并不存在。

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

请注意,这只会加载文件,它不会运行php文件,除非您使用php运行时。