Last active
May 14, 2016 11:51
-
-
Save biodunalfet/d083794ff7cc5d9335c59677ac0571b2 to your computer and use it in GitHub Desktop.
Files for the Getting Started with Google App Engine for the Google Cloud Platform Next Extended 2016 Ibadan event delivered by Hamza Fetuga (hfetuga@gmail.com)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python27 | |
api_version: 1 | |
threadsafe: true | |
handlers: | |
- url: /.* | |
script: helloworld.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python27 | |
api_version: 1 | |
threadsafe: yes | |
handlers: | |
- url: /.* | |
script: gcp_next.app | |
libraries: | |
- name: webapp2 | |
version: "2.5.2" | |
- name: jinja2 | |
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud preview app deploy app.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/fizzbuzz"> | |
Enter n:<br> | |
<input type="text" name="n" value="" id="n"><br> | |
<input type="submit" value="Submit"> | |
</form> | |
<ol> | |
{% for a in range(1, n + 1) %} | |
{% if a % 3 == 0 and a % 5 == 0 %} | |
<li>FizzBuzz</li> | |
{% elif a % 3 == 0 %} | |
<li>Fizz</li> | |
{% elif a % 5 == 0 %} | |
<li>Buzz</li> | |
{% else %} | |
<li>{{a}}</li> | |
{% endif %} | |
{% endfor %} | |
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webapp2 | |
import jinja2 | |
import os | |
jinja_env = jinja2.Environment( | |
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), | |
extensions=['jinja2.ext.autoescape'], | |
autoescape=True) | |
form = """<a href="/fizzbuzz">FizzBuzz</a>""" | |
class MainPage(webapp2.RequestHandler): | |
def get(self): | |
#self.response.headers['Content-Type'] = 'text/plain' | |
self.response.write(form) | |
class Handler(webapp2.RequestHandler): | |
def write(self, *a, **kw): | |
self.response.out.write(*a, **kw) | |
def render_str(self, template, **params): | |
t = jinja_env.get_template(template) | |
return t.render(params) | |
def render(self, template, **kw): | |
self.write(self.render_str(template, **kw)) | |
class FizzBuzzHandler(Handler): | |
def get(self): | |
n = self.request.get('n', 0) | |
n = n and int(n) | |
self.render("fizzbuzz.html", n = n) | |
app = webapp2.WSGIApplication([ | |
('/', MainPage), ('/fizzbuzz', FizzBuzzHandler) | |
], debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webapp2 | |
class MainPage(webapp2.RequestHandler): | |
def get(self): | |
self.response.headers['Content-Type'] = 'text/plain' | |
self.response.write('Hello, World!') | |
app = webapp2.WSGIApplication([ | |
('/', MainPage), | |
], debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev_appserver.py ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat > filename | |
Then you paste the content | |
Then use Ctrl + D to save and exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
touch filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim filename | |
Press a to start editing | |
Do your editing | |
When you're done, press Esc | |
Then type ":wq" to write/save and quit/exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment