0

I take web application course this semester and I want to use google application engine to implement my course project, but I'm wondering if GAE can satisfy this project's requirements. This course project is a homework submittal system which allows users(students) uploading homework to the sever and teachers checking homework online.

Assuming homework students uploaded is some html and css stuff. What confused me is how to implemnent teacher checking online function? For example:

Student A uploaded a html file hello.html and teacher want to use http: //xxx.xx/xx/xx/hello.html to check this homework.

Can GAE satisfy this requirement? As far as I konw, GAE uses app.yaml to point to different files or htmls, but when students upload their homework, they can not change app.yaml,right?

I get stuck here. Please help me. Thank you!

hakunami
  • 2,351
  • 4
  • 31
  • 50

2 Answers2

4

Yes, you can use GAE to create this application, but you'll have to move away from the idea that you are uploading and serving an HTML file as if it were living directly on the filesystem. You can't do that.

What you can do -- relatively easily -- is store the submitted file or files as datastore objects and provide a URL which takes the desired filename as a parameter and serves it out of the datastore.

You could store the submitted files in a model like this:

class HomeworkItem(db.Model):
    author = db.UserProperty()
    filename = db.StringProperty()
    content = db.TextProperty(multiline=True)
    submitted_on = db.DateProperty()

The content field is declared as a TextProperty assuming that you are dealing with HTML and CSS files, but if you were ever going to deal dealing with binary data, you'd want to use a BlobProperty.

You'd need to have two URLs to handle upload and download of assets. You can use a web framework or write some code to handle parameterized URLs, allowing you to encode things like the filename into the URL itself, like this:

http://homeworkapp.edu/review/hello.html

And then the method that handles /review/* URLs would retrieve the data from the datastore and send it back as the reply.

Adam Crossland
  • 14,198
  • 3
  • 44
  • 54
  • Awesome! Thank you for enlightening me! – hakunami Apr 30 '12 at 13:53
  • 2
    And then your cleverer students can upload homework with an XSS attack in it that steals the teacher's credentials, and log in and change their grades. Be very, very careful serving user-generated content back to other users, particularly HTML. – Nick Johnson May 01 '12 at 02:47
  • An excellent point, Nick. Feasibility and advisability are very different things, and this project idea has a lot going against it. – Adam Crossland May 01 '12 at 13:10
0

GAE would satisfy your requirement but you would need to save each “hello.html” file in either the Blobstore or the Datastore and build some system to retrieve and serve the uploaded files. See this Q&A for further reference.

Community
  • 1
  • 1
Arne S
  • 1,004
  • 14
  • 41