Skip to content

Instantly share code, notes, and snippets.

@jimmykane
Last active December 31, 2015 04:29

Revisions

  1. jimmykane revised this gist Dec 12, 2013. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -13,11 +13,17 @@
    template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))


    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    # Do your stuff here
    pass

    class UploadFormHandler(webapp2.RequestHandler):

    def get(self):

    upload_url = blobstore.create_upload_url('/upload/')
    upload_url = blobstore.create_upload_url('/upload/')
    template = template_env.get_template('blob.html')
    context = {
    'upload_url': upload_url
  2. jimmykane revised this gist Dec 12, 2013. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,6 @@
    template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))


    def get(self):
    #Here goes anything you want on /


    class UploadFormHandler(webapp2.RequestHandler):

    def get(self):
  3. jimmykane revised this gist Dec 12, 2013. 1 changed file with 9 additions and 21 deletions.
    30 changes: 9 additions & 21 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -2,43 +2,31 @@
    @author: Dimitrios Kanellopoulos
    @contact: jimmykane9@gmail.com
    '''
    import os
    import logging

    import webapp2

    import jinja2


    import os

    import webapp2
    import jinja2

    from google.appengine.ext import blobstore

    template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))

    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    #Here goes anything you want on /


    class UploadFormHandler(webapp2.RequestHandler):

    upload_url = blobstore.create_upload_url('/blob/')
    def get(self):

    upload_url = blobstore.create_upload_url('/upload/')
    template = template_env.get_template('blob.html')
    context = {
    'upload_url': upload_url
    }
    self.response.write(template.render(context))

    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    #Here goes anything you want on /


    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    #Here goes anything you want on /


    class UploadFormHandler(webapp2.RequestHandler):
    @@ -57,7 +45,7 @@ def post(self):
    ("/upload/", UploadFormHandler),
    ('/upload/picture/', PictureUploadHandler),

    ],debug=True, config=config.config)
    ],debug=True)



  4. jimmykane created this gist Dec 12, 2013.
    71 changes: 71 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    '''
    @author: Dimitrios Kanellopoulos
    @contact: jimmykane9@gmail.com
    '''
    import logging

    import webapp2

    import jinja2


    import os

    import webapp2
    import jinja2

    from google.appengine.ext import blobstore

    template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))

    class MainPageHandler(webapp2.RequestHandler):

    def get(self):

    upload_url = blobstore.create_upload_url('/blob/')
    template = template_env.get_template('blob.html')
    context = {
    'upload_url': upload_url
    }
    self.response.write(template.render(context))

    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    #Here goes anything you want on /


    class MainPageHandler(webapp2.RequestHandler):

    def get(self):
    #Here goes anything you want on /


    class UploadFormHandler(webapp2.RequestHandler):

    def post(self):

    blobs = self.get_uploads('upload')
    # So some logging here and concept to store the reference of the blob key.
    #self.redirect('/')


    app = webapp2.WSGIApplication([

    # Essential handlers
    ("/", MainPageHandler),
    ("/upload/", UploadFormHandler),
    ('/upload/picture/', PictureUploadHandler),

    ],debug=True, config=config.config)




    # Extra Hanlder like 404 500 etc
    def handle_404(request, response, exception):
    logging.exception(exception)
    response.write('Oops! Naughty Mr. Jiggles (This is a 404)')
    response.set_status(404)

    app.error_handlers[404] = handle_404