简体   繁体   English

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

[英]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 : 基本上我是google app引擎的新手,我有一个名为templates的文件夹,其中有几个文件:

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. 但是在yaml.app上我只想出了如何通过制作templates / index.php默认页面来本地运行服务器。 I mean when I go to http://localhost:8080 it is what I see. 我的意思是当我去http://localhost:8080这就是我所看到的。 But when I do http://localhost:8080/templates/index.php it says 404 not found. 但是,当我执行http://localhost:8080/templates/index.php它说404找不到。 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? 如何在我的应用程序内的任何目录中使用我想要的所有文件,是否应该添加到我的app.yaml中的某些规则?

Here is the current app.yaml im using : 这是当前的app.yaml即时通讯使用:

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 Shell.application是我编辑的python脚本,默认使用templates / index.php

I'm assuming index.php is a script? 我假设index.php是一个脚本?

I believe you have to run php scripts using the php runtime. 我相信你必须使用php运行时运行php脚本。 They won't run as scripts from the python runtime, so firstly, you won't be able to run the php scripts. 它们不会作为python运行时的脚本运行,所以首先,你将无法运行php脚本。

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. 请注意,这只会加载文件,除非您使用的是php运行时,否则它不会运行php文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine - 从同一目录提供 php 和静态内容 - Google App Engine - serve php and static content from same directory 用于joomla中静态文件的Google应用引擎 - Google app engine for static files in joomla Google App Engine app.yaml匹配所有PHP文件并匹配所有HTML文件并分别投放 - Google App Engine app.yaml match all PHP files and match all HTML files and serve respectively Google App Engine:如何在 PHP 循环中从 Google 云存储提供上传的图像 - Google App Engine: How to serve uploaded images in a PHP loop from google cloud storage 用于php静态文件的google app引擎app.yaml无法加载 - google app engine app.yaml for php static files don't load 如何在Nginx上的论坛子文件夹中提供静态文件? - How to serve static files in forum subfolder on nginx? Google App Engine提供Content-Length标头 - Google App Engine serve Content-Length header 如何使.mo文件可用于Google App Engine? - How to make .mo files available to Google App Engine? 如何查看文件部署到Google App Engine的php应用程序 - How to view files a php application deployed to google app engine 如何在运行PHP 7.2的localhost Google App Engine上上传文件? - How to upload files on localhost Google App Engine running PHP 7.2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM