Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c36e08

Browse files
author
jrocha
committed
Initial import
git-svn-id: svn://209.62.64.234/myblobstorage/trunk@1 cf2837ac-3b0f-0747-bb9c-85b6cd84a406
0 parents  commit0c36e08

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

‎app.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
application:myblobstorage
2+
version:3
3+
runtime:python
4+
api_version:1
5+
6+
handlers:
7+
-url:/static
8+
static_dir:static
9+
10+
-url:/.*
11+
script:myblobstorage.py
12+

‎index.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
indexes:
2+
3+
# AUTOGENERATED
4+
5+
# This index.yaml is automatically updated whenever the dev_appserver
6+
# detects that a new type of query is run. If you want to manage the
7+
# index.yaml file manually, remove the above marker line (the line
8+
# saying "# AUTOGENERATED"). If you want to manage some indexes
9+
# manually, move them above the marker line. The index.yaml file is
10+
# automatically uploaded to the admin console when you next deploy
11+
# your application using appcfg.py.

‎myblobstorage.py‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
importcgi
2+
3+
fromgoogle.appengine.apiimportusers
4+
fromgoogle.appengine.extimportwebapp
5+
fromgoogle.appengine.ext.webapp.utilimportrun_wsgi_app
6+
fromgoogle.appengine.extimportdb
7+
fromgoogle.appengine.apiimporturlfetch
8+
fromgoogle.appengine.apiimportimages
9+
10+
classPhoto(db.Model):
11+
blob=db.BlobProperty()
12+
13+
classMainPage(webapp.RequestHandler):
14+
defget(self):
15+
self.response.out.write('<html><body>')
16+
self.response.out.write('<form action="/uploadPhoto" method="POST" enctype="multipart/form-data">')
17+
self.response.out.write("""
18+
<div><input type="file" name="photoFile"></div>
19+
<div><input type="submit" value="Upload"></div>
20+
</form>
21+
</body>
22+
</html>""")
23+
24+
classViewPhoto(webapp.RequestHandler):
25+
defget(self,key):
26+
photo=db.get(key)
27+
self.response.headers['Content-Type']='image/png'
28+
self.response.out.write(photo.blob)
29+
30+
31+
classUploadPhoto(webapp.RequestHandler):
32+
defpost(self):
33+
markResponse=urlfetch.fetch('http://myblobstorage.appspot.com/static/timestamp.png');
34+
mark=markResponse.content;
35+
36+
imageBlob=self.request.get('photoFile');
37+
image=images.Image(imageBlob);
38+
39+
new_image=images.composite(
40+
[
41+
(imageBlob,0 ,0,1.0,images.TOP_LEFT),
42+
(mark,0 ,0,0.5,images.TOP_LEFT)
43+
],
44+
image.width,
45+
image.height,
46+
0,
47+
images.PNG)
48+
49+
50+
photo=Photo()
51+
photo.blob=new_image
52+
photo.put()
53+
self.response.out.write('<html><body>Photo uploaded! Id = %s'%photo.key())
54+
self.response.out.write('<br><a href="/viewPhoto/%s">link</a></body></html>'%photo.key())
55+
56+
application=webapp.WSGIApplication(
57+
[('/',MainPage),
58+
('/uploadPhoto',UploadPhoto),
59+
('/viewPhoto/([-\w]+)',ViewPhoto)],
60+
debug=False)
61+
62+
defmain():
63+
run_wsgi_app(application)
64+
65+
if__name__=="__main__":
66+
main()
67+

‎static/test.png‎

1.58 KB
Loading

‎static/timestamp.png‎

1.32 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp