Assignment Exercise - Hello World

Hello World App



Create New Project

At home dashboard click on the 3 circles next to the current project name to get to the project dashboard





On the top left hand side of the screen click on new project



Enter a unique name for the project that is descriptive and you can remember


Click on create the project


Next let's go into the Cloud linux shell upper left hand corner by clicking the  >- sign




Welcome to Cloud Shell! Type "help" to get started.Your Cloud Platform project in this session is set to uconn-app-helloworld.Use “gcloud config set project [PROJECT_ID]” to change to a different project.john_iacovacci1@cloudshell:~ (uconn-app-helloworld)$

Create a directory for the project mkdir helloworld

and change to the directory of the project cd helloworld

john_iacovacci1@cloudshell:~ (uconn-app-helloworld)$ mkdir ~/helloworldjohn_iacovacci1@cloudshell:~ (uconn-app-helloworld)$ cd ~/helloworldjohn_iacovacci1@cloudshell:~/helloworld (uconn-app-helloworld)$




Use the Open Editor button in the right hand side of the screen to allow for the code to placed into the project directory

 


Highlight the helloworld directory


Go to the file menu and select create new file


type in main.py (note all app engine python processes start with main.py)



  main.py
========================================================================     from flask import Flask



# If `entrypoint` is not defined in app.yaml, App Engine will look for an app

# called `app` in `main.py`.

app = Flask(__name__)





@app.route('/'methods=['GET'])

def hello():

    """Return a friendly HTTP greeting."""

    return 'Hello World!\n'





if __name__ == '__main__':

    # Used when running locally only. When deploying to Google App

    # Engine, a webserver process such as Gunicorn will serve the app. This

    # can be configured by adding an `entrypoint` to app.yaml.

    app.run(host='localhost'port=8080debug=True)
========================================================================
cut and paste the code above into the on screen editor





Note: This web app is a simple web service responding to HTTP GET requests with the message Hello World!.

Create a new file for requirements.txt (note: the helloworld directory needs to be highlighted when creating the file)



requirements.txt
========================================================================
Flask==1.1.1
========================================================================

cut and paste into the file (note: may need to use ctrl-v to paste)



Again making sure the helloworld directory is selected create a new file called app.yaml

 


app.yaml
========================================================================
runtime: python37
========================================================================
cut and paste into the file (note: may need to use ctrl-v to paste)
 



next use menu to file save all

 

toggle back to terminal mode by clicking Open Terminal on right hand side of the screen.



While positioned within the helloworld directory type

gcloud app deploy

john_iacovacci1@cloudshell:~/helloworld (uconn-app-helloworld)$ gcloud app deploy


Choose 14 for us-east-1




Select Y when asked Do you want to continue




Finally the app is deployed



Beginning deployment of service [default]...╔════════════════════════════════════════════════════════════╗╠═ Uploading 3 files to Google Cloud Storage ═╣╚════════════════════════════════════════════════════════════╝File upload done.Updating service [default]...done.Setting traffic split for service [default]...done.Deployed service [default] to [https://uconn-hello-world.appspot.com]You can stream logs from the command line by running: $ gcloud app logs tail -s defaultTo view your application in the web browser run: $ gcloud app browsejonathaniacovacci@cloudshell:~/helloworld (uconn-hello-world)$



To execute go to compute and select app engine and Dashboard




Click the link to your application 





Hello World App













No comments:

Post a Comment

Office hours tomorrow(Tuesday) 5:00pm-6:00pm, 4/26/2021, 5:13 PM, English, 4/26/2021, 5:13 PM

Your assigned language is: English Classroom blog: googleclouduconn.blogspot.com 4/26/2021, 5:13 PM Office hours tomorrow(Tuesday) 5...