google interactive shell - google-app-engine

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

Related

dev_appserver.py with runtime go111 url dispatch problem

I am still working to get my old style appengines to work under at least go111 (go112 would not work due to dependencies on memcache). I am now stumbling over app.yaml configuration issues with my static files, I used a completely static directory layout before and just specified a few dynamic handlers in the root like this:
runtime: go111
handlers:
- url: /_ah/.*
script: auto
login: admin
secure: always
- url: /dynamic
script: auto
secure: always
- url: /admin/.*
script: auto
login: admin
secure: always
- url: (.*)/
static_files: html\1/index.html
upload: html/index.html
secure: always
- url: /(.*\.map)
mime_type: application/json
static_files: html/\1
upload: html/(.*\.map)
secure: always
- url: /
static_dir: html
secure: always
dev_appserver.py will never call my dynamic entry point. In production this does work, but I am still working on the conversion and would like to test locally. Any hints how to convince dev_appserver.py to let me do this? By the way my gcloud tools are updated as of today.
Your question is why your application works well when you deploy it to production but doesn't work when you use dev_appserver.py to run it locally, and how could you run it with dev_appserver.py. The answer to that is:
You won't be able to run it locally properly using dev_appserver.py, since it does not support runtime Go 1.11. Look at the Local Development Server Options documentation, there's only a link for "Go 1.9".
(as you can see, the links for "Go 1.11" and "Go 1.12" are disabled, which translates to: not supported.)
Documentation for Go 1.11 on App Engine Standard states that in order to test your application locally you would have to use "go run" command (notice how it doesn't mention dev_appserver.py tool). The command would be something like this:
go run [build flags] [-exec xprog] package [arguments...]
For more information about the command go here.
I'm sure you might have already read this but, to know more about the migrations process from Go1.9 to Go1.11 read this documentation.
You have stated that "go run" command wouldn't work for your case. So, a workaround for that would be to test your application directly into App Engine but without migrating the traffic.
When deploying your test version use:
gcloud app deploy --no-promote
To access to it go to:
http://VERSION_ID.default.YOUR_PROJECT_ID.appspot.com
If everything turned out great, you can migrate the traffic on the Cloud Console UI selecting the version you just deployed and clicking "Migrate traffic".

How to serve source folder on Google App Engine?

The below app.yaml pasted below gives error:
sre_constants.error: cannot refer to open group
application: villagegamedev
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /(.*)
static_files: ./\1
upload: ./\1
My express purpose for this test is to serve the source folder. When I Google this effort, the search only comes up with all the docs that say "App Engine does not serve files directly out of your application's source directory unless configured to do so." So how do I configure it to do so?
handlers:
- url: /
static_dir: static
Then just put all of the files you want to serve in a directory named static.
This link gives a full description.
Basically what you should do is;
Create a project on google cloud platform
Create a directory on your computer with the same name as the
project created above. Create your app.yaml file here.
Paste this code into the app.yaml file
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
Install the google sdk into this folder (browse and select this
folder when prompted during installation).
Create a directory named www in your project folder. Save your static website files here.
Start up the google cloud sdk on your computer and run the following command
gcloud app deploy
7.run gcloud app browse to see your website in your browser.
Hope that helps!

How to write app.yaml for vast php project?

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.

Google Endpoints, the API explorer works locally but does not work after deployment

worked perfectly locally but the explorer is stuck in "Loading.." when deployed. Steps I took so far:
cleared browser cache
checked the logs, I have no errors and i DONT see a
"/_ah/spi/BackendService.getApiConfigs 200 " request, so thats a
issue and I dont know how to fix.
The link:
https://.appspot.com/_ah/spi/BackendService.getApiConfigs
results in: {"state": "APPLICATION_ERROR", "error_message": "Not
Found"}
Please point me in the right direction to debug this. thanks in advance
my app.yaml file
application: appID
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
# Endpoints handler
- url: /_ah/spi.*
script: the_api.APPLICATION
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /js
static_dir: static/js
- url: /.*
script: the_web_page.app
secure: always
libraries:
- name: webapp2
version: "2.5.2"
- name: endpoints
version: 1.0
- name: jinja2
version: latest
- name: pycrypto
version: latest
I had a simple error. To fix I changed the line
- url: /_ah/spi.*
in the app.yaml file to
- url: /_ah/spi/.*
what I find hard to explain is why the first worked in localhost.
I also had the yellow "Loading" status in my API Explorer on deployment and I was struggling to understand why - I had not changed any of my code but suddenly the API explorer stopped working.
All I did was to clear out my internet explorer temporary files, cookies and website data and it worked again.
This happens to me whenever I use Opera.i don't know if this is what you are using but try another browser.
Make sure you are using HTTPS. Endpoints in production only work using a secure connection.
It suddenly stopped working.
When I click on the Endpoint, it just change the url in the address bar of the browser but doesn't load it.
So I copied the url from the address bar and loaded the url directly and it worked.

app.yaml configuration for php-generated ajax response

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?

Resources