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
Create a directory for the project mkdir helloworld
and change to the directory of the project cd 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=8080, debug=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
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