0

For GAE, in python 3.7, using flask, gcloud on windows 10. Trying to put in place a service-worker, I spend 2 days not being able to load the service-worker.js file. On localhost if the file is in the root folder, the file in inaccessible, but if I move the file to the static folder, first I have an error because the index.html is on the root but not the service worker file, and second the mine type of the sevrice worker file is text/html. I figure I need to change the app.yaml file to specify the mine type but it doesn't seem to have any effect. After erasing everything in the app.yaml, I realize that it is not affecting the localhost. I deployed the project and it works on the gae sever. I would like to be able to test the service-worker locally. I am missing something? Loading successfully on GAE: enter image description here

But 404 on localhost: enter image description here

You can notice the same problem with the manifest file situated in the root folder.

Thanks.

  • Please show your service's `.yaml` file and file/dir structure - locations of service files relative to the service's `.yaml` file matters. Also please mention if this is a single-service app context or a service inside a multi-services app. – Dan Cornilescu Oct 13 '19 at 20:14
  • The .yaml is fine, once the project is deployed, everything works as expected. I was finally able to find out that simply running the project using «python main.py» doesn't use the app.yaml, you should use dev_appserver.py which doesn't work with a project using python 3.x, or gunicorn that doesn't run on windows. Actually compiling python 3.7 on debian to try run the project on linux-subsystem for windows. Debian only has 3.5, but 3.6 and more si needed for ndb. – Stephane Duteriez Oct 15 '19 at 20:31
  • Please check out this [SO case](https://stackoverflow.com/questions/44081610/service-worker-in-root-on-gae) it may come in handy for what you are trying to achieve. Otherwise, let me know and I'll take a deeper look into it. – sllopis Oct 16 '19 at 08:15

1 Answers1

1

As the install process stipulate, dev_appserver doesn't work on windows with python 3. The solution was to install a linux subsystem for windows : https://learn.microsoft.com/en-us/windows/wsl/install-win10

I use the Ubuntu app from the windows store, and follow the installation for installing the gcloud component on linux inside the ubuntu terminal: https://https://learn.microsoft.com/en-us/windows/wsl/install-win10cloud.google.com/sdk/docs/#deb

Inside the Ubuntu terminal it is possible to access the windows file : the C drive would be /mnt/c. Getting back to my work folder, it is possible to start the web-app using the dev_appserver command.

Using a navigator from windows we have access to the web-app as normal using localhost:8080.

The development can still be done using an IDE in windows, running the server in Ubuntu.