Getting Started with Google App Engine for Python & PHP

reference

gae.png

Download SDK for Python

python


unzip google_appengine_1.9.25.zip
mv google_appengine ~/bin/

~/.bashrc


export PATH=$PATH:$HOME/bin/google_appengine

Source

python


wget https://console.developers.google.com/project/Project ID/start/appengine
unzip master.zip
cd appengine-try-python-bottle-master/
appcfg.py -A Project ID update.

The WEB browser starts and "The authentication flow has completed." Is displayed.

Success if "Hello World!" Is displayed.

How to reflect the correction

main.py


 def hello():
     """Return a friendly HTTP greeting."""
-    return 'Hello World!'
+    return 'Hello'

python


appcfg.py -A Project ID update.

Success if it is displayed as "Hello"


PHP

python


wget https://github.com/GoogleCloudPlatform/appengine-try-php/archive/master.zip
unzip master.zip
cd appengine-try-php-master

python


appcfg.py -A Project ID update.

Success if "Hello World!" Is displayed.

How to reflect the correction

helloworld.php


 <?php
-  echo 'Hello, world!';
+  echo 'Hello PHP';

python


appcfg.py -A Project ID update.

Success if it is displayed as "Hello"

Add routing

app.yaml


 handlers:
-- url: /.*
-   script: helloworld.php
+- url: /
+  script: index.php
+- url: /1
+  script: 1.php

This way, when / is accessed, index.php When / 1 is accessed, 1.php is processed.


Data storage

Preparation: Make a Bucket

How to save data

helloworld.php


define(BUCKET, "gs://mybucket");

# text/Save as plain
$options = [ "gs" => [ "Content-Type" => "text/plain" ]];
$ctx = stream_context_create($options);
file_put_contents(BUCKET."/hello.txt", "Data 1", 0, $ctx);

# binaly/octet-Save as stream
$fp = fopen(BUCKET."/hello2.txt", "w");
fwrite($fp, "Data 2");
fclose($fp);

Confirm that the data is saved in the bucket.

スクリーンショット 2015-09-01 11.14.14.png

Recommended Posts

Getting Started with Google App Engine for Python & PHP
PIL with Python on Windows 8 (for Google App Engine)
Getting Started with Python for PHPer-Functions
Getting Started with Python for PHPer-Super Basics
1.1 Getting Started with Python
Getting Started with Python
Getting Started with Python
[Translation] Getting Started with Rust for Python Programmers
Tweet (API 1.1) on Google App Engine for Python
Settings for getting started with MongoDB in python
Getting Started with Python Functions
Getting Started with Python Django (1)
Getting Started with Python Django (4)
Getting Started with Python Django (3)
Getting Started with Python Django (6)
Python3 | Getting Started with numpy
Getting Started with Python Django (5)
Getting Started with Python responder v2
Getting Started with Python Web Applications
Google App Engine development with Docker
Getting Started with Julia for Pythonista
Getting Started with Python Basics of Python
Getting Started with Python Genetic Algorithms
Getting started with Python 3.8 on Windows
Getting Started with python3 # 1 Learn Basic Knowledge
Building a Windows 7 environment for getting started with machine learning with Python
Getting Started with Python Web Scraping Practice
[Python] Run Flask on Google App Engine
Getting Started with Python Web Scraping Practice
Getting started with Dynamo from Python boto
I can't deploy with google app engine
Getting Started with Lisp for Pythonista: Supplement
Getting Started with Heroku, Deploying Flask App
Deploy a Python app on Google App Engine and integrate it with GitHub
Getting started with Python with 100 knocks on language processing
Getting started with AWS IoT easily in Python
Materials to read when getting started with Python
Django 1.11 started with Python3.6
Getting started with Android!
Getting Started with Golang 2
Getting Started with Golang 1
Getting Started with Django 1
Getting Started with Optimization
Getting Started with Golang 3
Getting Started with Numpy
Getting started with Spark
Getting Started with Pydantic
Getting Started with Golang 4
Getting Started with Jython
Getting Started with Django 2
Getting Started with python3 # 2 Learn about types and variables
Deploy a Django application on Google App Engine (Python3)
Google App Engine / Python development environment construction procedure (late 2014)
How to use Django on Google App Engine / Python
Runtime version of Google App Engine / Python Standard Environment
Various memorandums when using sdk of LINE Messaging API with Python (2.7.9) + Google App Engine
Translate Getting Started With TensorFlow
Getting Started with Tkinter 2: Buttons
Getting Started with Go Assembly
Getting Started with PKI with Golang ―― 4
Study Python with Google Colaboratory