Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to show txt on web, by gae,google app engine,python
    primarykey
    data
    text
    <p>i want to upload txt file and show this txt.</p> <p>i had the code of uploading txt to gae, but how to show it???</p> <p>i want to upload txt file and show this txt.</p> <p>i had the code of uploading txt to gae, but how to show it???</p> <p>i want to upload txt file and show this txt.</p> <p>i had the code of uploading txt to gae, but how to show it???</p> <pre><code> import os import urllib 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 import template from google.appengine.ext.webapp.util import run_wsgi_app class MainHandler(webapp.RequestHandler): def get(self): upload_url = blobstore.create_upload_url('/upload') self.response.out.write('&lt;html&gt;&lt;body&gt;') self.response.out.write('&lt;form action="%s" method="POST" enctype="multipart/form-data"&gt;' % upload_url) self.response.out.write("""Upload File: &lt;input type="file" name="file"&gt;&lt;br&gt; &lt;input type="submit" name="submit" value="Submit"&gt; &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;""") for b in blobstore.BlobInfo.all(): self.response.out.write('&lt;li&gt;&lt;a href="/serve/%s' % str(b.key()) + '"&gt;' + str(b.filename) + '&lt;/a&gt;') class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads('file') blob_info = upload_files[0] self.redirect('/') class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler): def get(self, blob_key): blob_key = str(urllib.unquote(blob_key)) if not blobstore.get(blob_key): self.error(404) else: self.send_blob(blobstore.BlobInfo.get(blob_key), save_as=True) def main(): application = webapp.WSGIApplication( [('/', MainHandler), ('/upload', UploadHandler), ('/serve/([^/]+)?', ServeHandler), ], debug=True) run_wsgi_app(application) if __name__ == '__main__': main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload