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 9226211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:46:30+00:00 2026-06-18T04:46:30+00:00

I’m making a simple app on GAE that allows a user to enter a

  • 0

I’m making a simple app on GAE that allows a user to enter a url to an image and a name. The app then uploads this image to the Datastore along with its name.

After the upload the page self redirects and then should send the image back to the client and display it on their machine.

The app runs, but no image is shown. The log message I get is:

AttributeError: ‘NoneType’ object has no attribute ‘image’

The python:

import jinja2   # html template libary
import os

jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

import urllib   
import urllib2 
import webapp2

from google.appengine.ext import db
from google.appengine.api import urlfetch


class Default_tiles(db.Model):
  name = db.StringProperty()
  image = db.BlobProperty(default=None)


class MainPage(webapp2.RequestHandler):
  def get(self):

    # this just prints out the url which the user enters into input
    image_name = self.request.get('image_name') 

    template_values = {
        'image_name': image_name,
    }

    template = jinja_environment.get_template('index.html')
    self.response.out.write(template.render(template_values))



class Upload(webapp2.RequestHandler):
  def post(self):

    # get information from form post upload
    image_url = self.request.get('image_url') 
    image_name = self.request.get('image_name')

    # create database entry for uploaded image 
    default_tile = Default_tiles()
    default_tile.name = image_name
    default_tile.image = db.Blob(urlfetch.Fetch(image_url).content)
    default_tile.put()

    self.redirect('/')


class Get_default_tile(webapp2.RequestHandler):
  def get(self):
    name = self.request.get('image_name')
    default_tile = self.get_default_tile(name)

    self.response.headers['Content-Type'] = "image/png"
    self.response.out.write(default_tile.image)

  def get_default_tile(self, name):
    result = db.GqlQuery("SELECT * FROM Default_tiles WHERE name = :1 LIMIT 1", name).fetch(1)
    if (len(result) > 0):
      return result[0]
    else:
      return None


app = webapp2.WSGIApplication([('/', MainPage),
                               ('/upload', Upload),
                               ('/default_tile_img', Get_default_tile)],
                              debug=True)

The HTML:

<html>
    <head>
        <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
    </head>

    <body>
        <form action="/upload" method="post">
            <div>
                <p>Name: </p>
                <input name="image_name">
            </div>
            <div>
                <p>URL: </p>
                <input name="image_url">
            </div>
            <div><input type="submit" value="Upload Image"></div>
        </form>
        <img src="default_tile_img?{{ image_name }}">

    </body>

</html>

Thanks for your help.

  • 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-18T04:46:32+00:00Added an answer on June 18, 2026 at 4:46 am

    First of all, you need to send the GET parameter back to your MainPage handler. This should work if you put it in your Upload Handler, on the redirect line:

    self.redirect('/?image_name=%s' % image_name)

    That will ensure that MainPage knows what image we just uploaded.

    The second problem was just your <img> tag in your template. It should be this:

    <img src="default_tile_img?image_name={{image_name}}">

    I’ve tested it on my end after making these changes, and it works.

    Everything was fine it seems, except your GET parameters. Just remember that when you pass a GET request, you need to specify it’s name and value, so that the your app can get it correctly from the headers. As an example, if you wanted the header to specify what an image_name is, you would pass this URL:

    http://domain.com/?image_name=name

    Instead of:

    http://domain.com/?name

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.