url not found when extending the default app engine url - google-app-engine

goolge engine app with default url - http://6.version.myapp.appspot.com/ works, but http://6.version.myapp.appspot.com/test gives me a :
404 Not Found.
The resource could not be found.
my app.yaml file is as follows :
application: myapp
version: 6
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /test
script: pythonfile.py
- url: /.*
script: pythonfile.
testing locally works fine : localhost:8080 and localhost:8080/test - both work fine.
Above the number 6 just happens to be a version no. So I am guessing for any other number the problem will happen. If I make the 6th version the default and access the url without version no, it works fine with and without the '/test' extension on the default url.

"6.version.yourapp.appspot.com" is not accessing version "6" of your app, it's accessing the version called "version". Thanks to wildcard subdomains, if that version doesn't exist, the request goes to your primary version.
I suspect you're thinking of the old version naming scheme, under which version 6 would be "6.latest.yourapp.appspot.com"; now it's simply "6.yourapp.appspot.com".

Are you sure your handler should look like that if you've got python 2.7? I think it should be eg handler.app instead of handler.py and if you follow the guestbook example from the SdK it probably does exactly what you are trying to do. You can also read Nick Johnson's blog post from blog.notdot.net how to upgrade to python 27 the official way - I don't think you put the script names in your app.yaml, I think it's supposed to look like
pythonfile.app
or
pythonfile.application
I hope this helps.

404 Not Found is from errors in app.yaml file, not your python coding. Look into the 'logs' of your appengine console and you'd find more information relating to this error. A good place to start is with GAE's Python 2.7 introduction page since it is too long to list here.
Changes aren't numerous though it can easily break your app if u miss a step (as it did to mine).

Related

Google App Engine providing .well-known Folder

I'm trying to provide a .well-known folder under my Google App Engine Application I'm using the standard environment and the python27 runtime.
with a web-app-origin-association.json file to try the Progressive Web Apps as URL Handlers
origin trial from chrome.
I've added the following code to my app.yaml file under handlers:
# .well-known Ordner
- url: /.well-known/(.*)
static_files: well-known/\1
upload: well-known/.*
The folder in my project is named well-known without a dot cause I've read that there are problems when using a folder Name with a dot at the start of the foldername.
But the url https://example.com/.well-known/web-app-origin-associate.json isn't available instead it works without the dot:
What do I have to change in order to make it work under https://example.com/.well-known/web-app-origin-association.json?
You can use the workaround documented at "Make skip_files rule explicit and tweak to allow .well-known/* to upload":
^(.*/)?\.(?!well-known(?:/|$)).*$
You many want to migrate to Python 3 as described in the guide:
Starting on January 1, 2020, the Python community will no longer
update, fix bugs, or patch security issues for Python 2.7. We
recommend that you update apps that are still running in the Python 2
runtime of the App Engine standard environment to the Python 3 runtime
as soon as possible.
The best way i found out about is to just do it like that:
- url: /\.well-known
static_dir: .well-known
secure: always
and use the python39 runtime.

Deploying an App with Code Splitting on GCP App Engine - Loading chunk * failed

We have a web application (frontend) using React created from Create React App. The app is running on Google Cloud Platform App Engine Standard. Our web application is code splitted. Each page is then loaded on user navigation.
It's working really well. The issue we have is for example user A is on the app home page. We deploy a fix that change the chunk file name. The user A then try to access another page and then got the error Loading chunk * failed. The url to get the file is now returning a 404 because the file has been replaced by some new chunk files.
It's a frequent problem as I can see during my research but I didn't find a solution that apply for Google App Engine.
Here's an article that explain the problem / solution: https://mitchgavan.com/code-splitting-react-safely/
I would like to use the solution "Solution 1: Keep old files on your server after a deployment" but I can't see how to do this using GCP ...
Here's the app.yaml file
service: frontend
runtime: nodejs14
env: standard
instance_class: F1
handlers:
- url: /(.*\..+)$
static_files: build/\1
upload: build/(.*\..+)$
- url: /.*
static_files: build/index.html
upload: build/index.html
We have the following dispatch file (* for masked url)
dispatch:
- url: "*"
service: frontend
- url: "www.*"
service: frontend
Haven't tried this before but see if it makes sense/works.
We have a blog article about downloading your source code from GAE. It contains an explanation of where your source is stored when you deploy (a staging bucket), how long it stays there and how you can modify how long it stays before Google automatically deletes it.
When you deploy to GAE, gcloud only deploys files that have changed (it doesn't deploy those that haven't). Since you now have 'new' files because new hashes were generated, the older files no longer exist on your local machine. I do not know if Google will automatically delete those files from the staging location in bullet 1 above.
My proposal here is that you follow the steps in the blog article (from bullet 1) and alter (change) how long the files are retained in your staging bucket. Another option is to check the retention policy tab and see if you can change the rule so the files don't get deleted. If you're able to alter how long the files remain or the retention policy, it just might solve your problem. Let me know if this works

Google App Engine import issue (golang) in "App Engine flexible environment" (formerly known as "Managed VMs")

I am developing an API in golang directly on the "App Engine flexible environment" (formerly known as "Managed VMs").
So far, i have been using this kind of import in my .go files :
import (
"appengine"
"appengine/datastore"
...)
Recently I decided to use Google Cloud Storage to store images. It requires the import of "cloud.google.com/go/storage". My problem is that i'm unable to deploy the app with this import (not found), or any other short version ("go/storage") like I use for the appengine import.
After much research, I found this : https://github.com/golang/appengine#user-content-3-update-code-using-deprecated-removed-or-modified-apis
It specifies how to migrate an application using short imports (deprecated, like mine) to full imports (with repository explicit like "google.golang.org/appengine")
I followed the procedure and used the script they provide to update my code (aefix). They also say to add this line to my app.yaml file :
vm : true
If I do, I got this error message running 'gcloud app deploy' :
ERROR: (gcloud.app.deploy) Your application does not satisfy all of the requirements for a runtime of type [go]. Please correct the errors and try again.
If I don't, none of my imports are working and I get the following error :
can't find import: "google.golang.org/appengine/datastore"
Here is my app.yaml file :
runtime: go
api_version: go2
#vm : true
handlers:
- url: /.*
script: _go_app
Of course, all the imports are on the server under $GOPATH/src/ so they're not really missing, more badly referenced I guess.
I'm stuck on this problem since several days, any help of any kind would be appreciated !
Thanks
So sorry - we have some docs to go update. You cannot use the golang/appengine package with the App Engine flexible environment. The aefix tool won't work here either. Instead of the App Engine Go SDK, you want to use the Go client library here:
https://github.com/GoogleCloudPlatform/google-cloud-go
If you were previously using vm:true, you will need to upgrade to env:flex - the instructions (and the note on the go app engine library) are here:
https://cloud.google.com/appengine/docs/flexible/go/upgrading
Let me know if you have any questions!

app.yaml working differently on Local and on the Cloud

I've been playing around with GAE for PHP. Here is my Github code and it is running at http://shining-weft-626.appspot.com/
~/form gives me a 404 online but works perfectly on my local machine. Someone help.
/form is (bizarrely) a reserved URL on appengine, you'll have to pick something else: docs
The URL /form is working fine.
You are getting 404's for the URLs /form/ and /forms, because they do not match anything in your app.yaml.
- url: /form
script: form.php
- url: /
script: index.php
You code looks correct, if you committed and pushed it as shown. I think that you may be getting an error when loading the app.yaml, because you point to directories that do not exist. Try adding /js and /images to your /assets directory. They are missing now. Commit, and push again.
(Or, delete those mappings from your app.yaml)

App script appengine tutorial using Go

On the tutorial for Apps Script/Appengine:
https://developers.google.com/apps-script/articles/appengine
When trying to run google_appengine/dev_appserver.py google-apps-script/ the response is:
WARNING 2012-09-06 14:56:33,570 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO 2012-09-06 14:56:33,840 appengine_rpc.py:163] Server: appengine.google.com
CRITICAL 2012-09-06 14:56:33,842 appcfg.py:561] The api_version specified in app.yaml (1) is not supported by this release of the SDK. The supported api_versions are ['3', 'go1'].
I have tried the following app.yaml, but it doesn't work.
application: google-apps-script-tutorial
version: 1
runtime: go
api_version: go1
handlers:
- url: /*
script: _go_app
Also with - url: /rpc and it doesn't work. Since the code is Python is it possible to get App script and Go linked up in app engine?
The code for that tutorial is in Python and Javascript. If you want to use the go runtime, you will have to rewrite the Python portion in Go.
That example demonstrates the use of a Google Apps Script frontend with a Google App Engine (GAE) backend written in Python. GAE currently runs apps written in Java, Python, Go and PHP.
That particular Python backend accepts and produces messages in JSON format. Therefore, to link Apps Script and Go similarly, using GAE or not, you would need to replicate the functionality of the Python backend using, probably, the net/http library and the encoding/json library.
For examples of using these libraries together, have a look at this, this and this.
For examples on using Go with GAE, have a look at this and this.
Hope that helps.

Resources