提出作品:THE 箱投げOnline
物理演算使った協力型アスレチックをつくろう
→足場用の箱持たせよう
→持ち上げた箱がいい感じの挙動するようにしよう
→箱投げてる方が楽しくなってきた
だいたいこんな経緯でできました。
application: hogehoge-applicationcrossdomain.xml ※セキュリティ設定は最も緩くしているので、必要に応じて設定すること。
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /crossdomain.xml
mime_type: text/xml
static_files: crossdomain.xml
upload: crossdomain.xml
- url: /simple_db
script: simple_db.app
crossdomain.xml
simple_db.py
<?xml version="1.0"?>この設定ファイルは此方のForumの投稿からお借りしたものです。
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
<!-- Most restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="none"/>
-->
<!-- Least restrictive policy: -->
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
<!--
If you host a crossdomain.xml file with allow-access-from domain=“*”
and don’t understand all of the points described here, you probably
have a nasty security vulnerability. ~ simon willison
-->
</cross-domain-policy>
from google.appengine.ext import dbあとはGAEにデプロイするだけである。
import webapp2
class SimpleDB(db.Model):
name = db.StringProperty(required=True)
data = db.StringProperty(required=False)
create_time = db.DateTimeProperty(auto_now_add=True)
update_time = db.DateTimeProperty(auto_now=True)
class SimpleDBHandler(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
if self.request.get('name'):
rank = 1
for record in SimpleDB.all().order('-data').fetch(10, 0):
self.response.out.write(str(rank)+'. '+record.data+'\r\n')
rank = rank + 1
else:
self.response.out.write("access denied.")
def post(self):
if self.request.get('name') and self.request.get('data'):
data = SimpleDB(name=self.request.get('name'), data=self.request.get('data'))
data.save()
else:
self.response.out.write("access denied.")
app = webapp2.WSGIApplication([('/simple_db', SimpleDBHandler)], debug=True)