Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:32:25+00:00 2026-06-01T08:32:25+00:00

I want to ask,i tried to call webapp.RequestHandler ,but this handler didn’t called: this

  • 0

I want to ask,i tried to call webapp.RequestHandler,but this handler didn’t called:
this is compress.py page:

from __future__ import with_statement
from google.appengine.api import files
import cgi, cgitb ; cgitb.enable()
import StringIO
import zipfile
from google.appengine.ext import blobstore
from google.appengine.ext import webapp
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext.webapp.util import run_wsgi_app
class zip(webapp.RequestHandler):
    def z(self):
        form = cgi.FieldStorage()
        zipstream=StringIO.StringIO()
        zfile = zipfile.ZipFile(file=zipstream,mode="w",compression=zipfile.ZIP_DEFLATED)     
        file_upload = form['file[]']
        data=file_upload.file.read()
        filename2 = file_upload.filename
        zfile.writestr(filename2,data)
        zfile.close()
        zipstream.seek(0)
        zip_file = files.blobstore.create(mime_type='application/zip',_blobinfo_uploaded_filename='test.zip')
        with files.open(zip_file, 'a') as f:
            f.write(zipstream.getvalue())
        files.finalize(zip_file)
        blob_key = files.blobstore.get_blob_key(zip_file)        
        self.response.out.write('<a href="download.py?key=%s">get zip</a>' %blob_key)

def main():
     application = webapp.WSGIApplication( [(r'/compress.py', zip)], debug=True)
     run_wsgi_app(application)
if __name__ == "__main__":
    main()

app.yaml:

application: my application
version: 1
runtime: python
api_version: 1

handlers:
- url: (.*)/
  static_files: static\1/index.html
  upload: static/index.html
- url: /compress.py
  script: compress.py
- url: /download.py
  script: download.py
- url: /decompress.py
  script: decompress.py

Project structure:

/index.html
/compress.py
/download.py

EDIT:
download.py:

from google.appengine.ext import blobstore
from google.appengine.ext import webapp
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext.webapp.util import run_wsgi_app
import urllib
from mimetypes import guess_type

def mime_type(filename):
    return guess_type(filename)[0]

class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
    def get(self):
        print "Doaa"
        blob_key = self.request.get('key')
        blob_key = str(urllib.unquote(blob_key))
        blob_info = blobstore.BlobInfo.get(blob_key)
        content_type1 =mime_type(blob_info.filename)
        save_as1 =  blob_info.filename
        self.send_blob(blob_info,content_type=content_type1,save_as=save_as1)



def main():

    #application = webapp.WSGIApplication([('/',ServeHandler),], debug=True)
    application = webapp.WSGIApplication([
            (r'/download.*', ServeHandler),
        ], debug=True)
    run_wsgi_app(application)
if __name__ == '__main__':
    main()

in this page now when i uploaded my application i get this output at this page(i believe that that this page-download.py-get the blob that has the specfic key in URL and download this file to my PC),but the result as:

Status: 200 OK Cache-Control: no-cache X-AppEngine-BlobKey: AMIfv96uuwRiM-nYO7sp7nPk5Ny0IDv1mrVCkBhFMPn9AUea4rRg5x8sVWlLFJNQ2PxSKD2s6VNVjiPPZFDyP33EegP_QzLYQEnHdSSj_qindkuqeWB7YYnSeReBDYWDAAOf566LCSyWrXBUPq0Z_NiGtZjyvM3-5exv3TxIOYc9PBYuTQ3Vpww Content-Type: application/zip Content-Disposition: attachment; filename="test.zip" Expires: Fri, 01 Jan 1990 00:00:00 GMT Content-Length: 0

without saving?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:32:27+00:00Added an answer on June 1, 2026 at 8:32 am

    Assuming you’re posting to /compress.py, replace

    def z(self):
    

    with

    def post(self):
    

    That’ll get you to your next problem.

    As an aside, you’ll probably find it easier to take smaller steps. A small step in this case would be “can I hit a handler via URL and at least get a ‘hello world’ result?”. Maybe you’ve already done that. The next small step is “Can I post to a handler and get a ‘hello world’ result?” Doing that without worrying at all (yet) about what to do with posted data removes a lot of possible problems from consideration. Take those problems on small step by small step.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call an external program from within python, but this external program
This is a painfully noob question, but I have to ask it. I want
want to ask user to input something but not want to wait forever. There
I want to ask how can someone read keystrokes while in a html page
I want to ask why we use this keyword before the parameter in an
I want to ask about this function in matlab dicomread example : a =
I really didn't want to ask for help as I know I'll eventually figure
I'm using a repeater on my page. I want to populate this repeater based
How'd I go about this one? I want to tween a value from one
Just want to make sure I understand this correctly (I'd ask on SO Chat,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.