python
unzip google_appengine_1.9.25.zip
mv google_appengine ~/bin/
~/.bashrc
export PATH=$PATH:$HOME/bin/google_appengine
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.
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.
helloworld.php
<?php
- echo 'Hello, world!';
+ echo 'Hello PHP';
python
appcfg.py -A Project ID update.
Success if it is displayed as "Hello"
$ _SERVER ["REMOTE_ADDR "]
Variables can be used normally, so access can be restricted and it seems convenient.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.
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.
Recommended Posts