Basic understanding about a web app.

  1. user send google.com –> request
  2. google.com send user –> response
  3. your browser is middle man which will help you send request and receive the response

We will create a web app to generate the response data base on user request.

Create app.yaml file

You can configure your App Engine application’s settings in the app.yaml file

app.yaml Reference

runtime: python27
api_version: 1
threadsafe: yes

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

Create main.py

webapp2 reference

# import the library
import webapp2

# === Pages ===


class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello, This\' Heosua website!')
        self.response.write('<br/><br/>')
        self.response.write('Nice to meet you')


class AboutPage(webapp2.RequestHandler):
    def get(self):
        self.response.write('I\'m Pham Hieu')

# === App Routing ===
# depend on user route input, we will send them to mainPage
# or aboutPage

app = webapp2.WSGIApplication([
    ('/', MainPage),
    ('/about', AboutPage),
], debug=True)

Run Debug

  1. Open your terminal
    cd your_project_folder
    
  2. Run command
    dev_appserver.py app.yaml
    
  3. Open your browser and access http://localhost:4000 to test your web app