Guest User

Untitled

a guest
Nov 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. import os
  2. import jinja2
  3. import webapp2
  4. import json
  5.  
  6. from google.appengine.ext import db
  7. from google.appengine.api import users
  8.  
  9. template_dir = os.path.join(os.path.dirname(__file__), 'templates')
  10. jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True)
  11.  
  12. class Times(db.Model):
  13. time = db.StringProperty(multiline = False)
  14.  
  15.  
  16. class Handler(webapp2.RequestHandler):
  17. def write(self, *a, **kw):
  18. self.response.out.write(*a, **kw)
  19.  
  20. def render_str(self, template, **params):
  21. t = jinja_env.get_template(template)
  22. return t.render(params)
  23.  
  24. def render(self, template, **kw):
  25. self.write(self.render_str(template, **kw))
  26.  
  27. class MainPage(Handler):
  28. def get(self):
  29. alltimes = db.GqlQuery("SELECT * FROM Times")
  30. self.render("index.html", alltimes = alltimes)
  31. def post(self):
  32. newtime = Times()
  33. newtime.time = self.request.get('time')
  34. newtime.put()
  35. self.response.out.write(self.request.get('time'))
  36.  
  37.  
  38. app = webapp2.WSGIApplication([
  39. ('/', MainPage),('/times', MainPage)
  40. ], debug=True)
  41.  
  42. application: ichronoapp
  43. version: 1
  44. runtime: python27
  45. api_version: 1
  46. threadsafe: yes
  47. handlers:
  48.  
  49. - url: /(.*.js)
  50. mime_type: text/javascript
  51. static_files: static/1
  52. upload: static/(.*.js)
  53.  
  54. - url: /favicon.ico
  55. mime_type: image/png
  56. static_files: static/favicon.ico
  57. upload: static/favicon.ico
  58.  
  59. - url: /(.*.css)
  60. mime_type: text/css
  61. static_files: static/1
  62. upload: static/(.*.css)
  63.  
  64. - url: /(.*.html)
  65. mime_type: text/html
  66. static_files: templates/1
  67. upload: templates/(.*.html)
  68.  
  69. - url: /(.*.ico)
  70. mime_type: image/x-icon
  71. static_files: static/1
  72. upload: static/(.*.ico)
  73. expiration: "7d"
  74.  
  75. - url: /(.*.json)
  76. mime_type: application/json
  77. static_files: static/1
  78. upload: static/(.*.json)
  79. expiration: "1s"
  80.  
  81. - url: /(.*.otf)
  82. mime_type: font/opentype
  83. static_files: static/1
  84. upload: static/(.*.otf)
  85.  
  86. - url: /(.*.(ttf|ttc))
  87. mime_type: application/x-font-ttf
  88. static_files: static/1
  89. upload: static/(.*.(ttf|ttc))
  90.  
  91. - url: /(.*.txt)
  92. mime_type: text/plain
  93. static_files: static/1
  94. upload: static/(.*.txt)
  95.  
  96. - url: /(.*.webp)
  97. mime_type: image/webp
  98. static_files: static/1
  99. upload: static/(.*.webp)
  100.  
  101. - url: /(.*.woff)
  102. mime_type: application/x-font-woff
  103. static_files: static/1
  104. upload: static/(.*.woff)
  105.  
  106. - url: /(.*.woff2)
  107. mime_type: application/x-font-woff
  108. static_files: static/1
  109. upload: static/(.*.woff2)
  110.  
  111. - url: /(.*.xml)
  112. mime_type: application/xml
  113. static_files: static/1
  114. upload: static/(.*.xml)
  115. expiration: "1h"
  116.  
  117. # image files
  118. - url: /(.*.(bmp|gif|jpeg|jpg|png))
  119. static_files: static/1
  120. upload: static/(.*.(bmp|gif|jpeg|jpg|png))
  121.  
  122. # audio files
  123. - url: /(.*.(mid|midi|mp3|wav))
  124. static_files: static/1
  125. upload: static/(.*.(mid|midi|mp3|wav))
  126.  
  127. # windows files
  128. - url: /(.*.(doc|exe|ppt|rtf|xls))
  129. static_files: static/1
  130. upload: static/(.*.(doc|exe|ppt|rtf|xls))
  131.  
  132. # compressed files
  133. - url: /(.*.(bz2|gz|rar|tar|tgz|zip))
  134. static_files: static/1
  135. upload: static/(.*.(bz2|gz|rar|tar|tgz|zip))
  136.  
  137. - url: /.*
  138. script: main.app
  139. libraries:
  140.  
  141. - name: jinja2
  142. version: latest
  143.  
  144. - name: webapp2
  145. version: latest
  146.  
  147. from google.appengine.ext import vendor
  148.  
  149. # Add any libraries install in the "lib" folder.
  150. vendor.add('lib')
Add Comment
Please, Sign In to add comment