简体   繁体   中英

Google App Engine Blank page localhost:8080

I am getting a blank page in "localhost:8080".

Followed the process mentioned in developers.google.com/appengine for python

Everything is working fine but the webpage is not displaying "hello world" as mentioned in the helloworld.py file.

import webapp2

class MainHandler(webapp2.RequestHandler):
def get(self):
    self.response.out.write('Hello world!')

app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)

and app.yaml file is

application: engineapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico

- url: .*
script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

First of all if your main file is named helloworld.py then you will have to change the line main.app to helloworld.app or change your filename to match the first part.

Also as Martijn already mentioned your indentation should be correct in order to see the Hello World! and in what you posted in your question is totally not.

Here is the corrected ones

import webapp2

class MainHandler(webapp2.RequestHandler):
  def get(self):
    self.response.out.write('Hello world!')

app = webapp2.WSGIApplication([
    ('/', MainHandler)
  ], debug=True)

and the app.yaml :

application: engineapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM