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?
Related
We are trying to access .json file inside our python code in Google App Engine.
Here is our app.yaml
service: worker
instance_class: F2
runtime: python27
api_version: 1
threadsafe: true
automatic_scaling:
max_instances: 100
min_pending_latency: 200ms # default value
max_pending_latency: automatic
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /images
static_dir: images
- url: /javascripts
static_dir: javascripts
- url: /(.*\.(gif|png|jpg|json))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg|json)$
application_readable: true
- url: /static
static_dir: static
application_readable: true
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /.*
script: worker.app
login: admin
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
We are using it in our application like this.
path = os.path.join(os.path.dirname(__file__)[0], '/static/google_web_app_script_credentials.json')
flow = InstalledAppFlow.from_client_secrets_file(path,self.GOOGLESHEETS_SCOPES )
But we are receiving the error.
IOError(2, 'No such file or directory')
We have tried various options of changing path including path = os.path.join(os.path.dirname(file)[0], '../static/google_web_app_script_credentials.json')
When we go to the GCP console -> Debug and review the current code we are able to see the .json file under static folder. This means that the file is there, we are not able to get the application to read it. This service is as "worker".
From your App Engine app, you don't have access to your static files. Move the file to another location within your project, and you will then be able to access it.
Even more importantly, you don't want to store credentials in your static folder! Anyone on the web will be able to access them via the URL!
My site has 8 pages and it is written in php: https://intercultural.appspot.com After deploying in GAE, it can load and dislpay the index.php page. However, does not display the other pages when I click on other links: Error: No Found The requested URL /file.php was not found on this server.
Here is the directory of my file: hightlighted in blue are the pages of my site.
enter image description here
Here is my app.yaml file:
runtime: php72 </b>
handlers:
# Serve a directory as a static resource.
- url: /styles
static_dir: styles
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
# Serve your app through a front controller at index.php or public/index.php.
- url: /(.+\.php)$
static_files: static/\1
upload: /(.+\.php)$
# I add the "/" to url bellow as suggested but still get same error
- url: /.*
script: auto
secure: always
Although it displays the site address in the browser, it says: Error: No Found The requested URL /file.php was not found on this server.
What is missing in the app.yaml file to route properly to the other pages of my site?
The URL for your final entry in the app.yaml should be url: /.* (with slash). This is necessary to match URLs of https://intercultural.appspot.com/*. You can see an example in the app.yaml reference.
I already fixed it.
The main problem was in the php version. I thought my code was written in php7.2 but actually it was php5.5, hence, the app.yaml didn't work properly.
Here is the app.yaml file:
This is my app.yaml file
runtime: php55
api_version: 1
handlers:
- url: /styles
static_dir: styles
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
application_readable: true
- url: /
script: index.php
secure: always
- url: /(.+\.php)$
script: \1
secure: always
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.
Hi i have setup an app engine account. everything works ok with standard php. i have a local install of fuelphp, this works with no issues when running the development server of google app engine. however once i move it to the production application, i get an error stating the cache directory is unwritable of non existent. i read through some articles and it mentioned the application sandbox on GAE is not writable, so i went and manually change the configurations to point to an external path for the cache, the issues is this persist. i even tried to remove the usage of cache, ( false in config ) and hardcoded remove by commenting out. this just crashed everyting.
app.yaml
env_variables:
FUEL_ENV: 'production'
handlers:
url: /(.*.(htm$|html$|css$|js$))
static_files: public/\1
upload: public/(.*.(htm$|html$|css$|js$))
application_readable: true
url: /(.*.(ico$|jpg$|png$|gif$))
static_files: public/\1
upload: public/(.*.(ico$|jpg$|png$|gif$))
application_readable: true
url: /assets
static_dir: public/assets
url: /favicon.ico
static_files: public/favicon.ico
upload: public/favicon.ico
url: /.*
script: public/index.php
Log file patch: https://github.com/isatan/FuelPHP4Gae_patch
Deploy SQL instance, load database schema and setup your production config.php to connect to in via unix socket.
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