How do I get a Python37 app working?

85 views
Skip to first unread message

Mark Summerfield

unread,
Apr 8, 2019, 11:04:47 AM4/8/19
to Google App Engine
I've created a new app with an `app.yaml` that has a runtime of python37 and that has some handlers, e.g.,
```yaml
runtime: python37

handlers:
- url: /query
  script: main.app

- url: /
  static_files: static/index.html
  upload: static/index.html

- url: /
  static_dir: static

```
I've installed Python 37 using virtualenv as the docs describe, as well as pip installing google-cloud-firestore and gunicorn.

But when I try running my app locally to test it, I get this output:
```
(env) : gunicorn -b localhost:8080 --reload --log-level debug main:app
[2019-04-08 15:54:50 +0100] [6243] [DEBUG] Current configuration:
... elided ...
[2019-04-08 15:54:50 +0100] [6243] [INFO] Starting gunicorn 19.9.0
[2019-04-08 15:54:50 +0100] [6243] [DEBUG] Arbiter booted
[2019-04-08 15:54:50 +0100] [6243] [INFO] Listening at: http://127.0.0.1:8080 (6243)
[2019-04-08 15:54:50 +0100] [6243] [INFO] Using worker: sync
[2019-04-08 15:54:50 +0100] [6246] [INFO] Booting worker with pid: 6246
[2019-04-08 15:54:50 +0100] [6243] [DEBUG] 1 workers
[2019-04-08 15:54:54 +0100] [6246] [DEBUG] GET /
[2019-04-08 15:55:06 +0100] [6246] [DEBUG] GET /index.html
```
which looks like there's nothing wrong.
But in the browser when I visit localhost:8080 (or 127.0.0.1:8080) I get a 404 file not found.

I've used GAE for years with appcfg and that was easy to test locally, but I can't figure this out.

Mark Summerfield

unread,
Apr 8, 2019, 11:25:05 AM4/8/19
to Google App Engine
I've now changed my app.yaml to this:
```
runtime: python37

handlers:
- url: /
  static_dir: static/
  static_files: static/index.html
- url: /.*
  script: auto
```
Now when I do localhost:8080/query etc. it works. But it does _not_ serve any static pages at all (and they're all there).

Mark Summerfield

unread,
Apr 8, 2019, 12:41:03 PM4/8/19
to Google App Engine
I've now changed `app.yaml` to this:

```
runtime: python37

handlers:
- url: /
  static_dir: static

- url: /.*
  script: auto
```
I have `main.py` in the root of my app dir and lots of `.html` files in the root of my app's `static` subdir. But still only the app pages handled by `main.py` appear; all the static html pages give a 404.

Mark Summerfield

unread,
Apr 8, 2019, 2:21:50 PM4/8/19
to Google App Engine
I've change the `app.yaml` file to match the docs:
```
runtime: python37

handlers:
- url: /static
  static_dir: static

- url: /.*
  script: auto
```
But I now realise that when I try to test the app, I don't use the yaml file at all because this is my command line for local testing:
`gunicorn -b localhost:8080 --reload --log-level debug main:app`
So that only knows about main.py; it doesn't know anything about the yaml file.

So, how do I do _local_ testing using the yaml file to serve up the static files and relying on main.py for the dynamic pages?

Mark Summerfield

unread,
Apr 9, 2019, 8:35:08 AM4/9/19
to Google App Engine
It seems that it isn't possible to test static files locally, so I'm going to stick with the original Python 2.7 SDK.

George (Cloud Platform Support)

unread,
Apr 9, 2019, 1:34:43 PM4/9/19
to Google App Engine
Hello Mark, 

There doesn't seem to be a compelling need to test static content locally. In fact, tutorial "Hosting a static website on Google App Engine" does not list this local testing step in its procedure. 

Khaled Wagdy

unread,
Apr 11, 2019, 4:33:01 PM4/11/19
to Google App Engine
Hello,

I am wondering why you are using gunicorn command and not just python main.app? What web framework are you using?

Mark Summerfield

unread,
Apr 12, 2019, 2:35:08 AM4/12/19
to Google App Engine
I have a compelling need: I want to test my whole website not just the generated portion.
Also, I can test the whole site using the old python27 SDK --- which is what I'm sticking with.

Nicolas (Google Cloud Platform Support)

unread,
Apr 12, 2019, 6:09:13 PM4/12/19
to Google App Engine
Hi Mark,

I understand that you will stick with the Python 2.7 and I don’t want to convince otherwise however I found this thread answered by a community member which I find very insightful.

Have a great day!
Reply all
Reply to author
Forward
0 new messages