Skip to content

Instantly share code, notes, and snippets.

@biodunalfet
Last active May 14, 2016 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biodunalfet/d083794ff7cc5d9335c59677ac0571b2 to your computer and use it in GitHub Desktop.
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)
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /.*
script: gcp_next.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
gcloud preview app deploy app.yaml
<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>
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)
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)
cat > filename
Then you paste the content
Then use Ctrl + D to save and exit
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment