The best way to talk from Flex to GAE is using AMF. Here is how:
app.yaml
application: flexandthecloud
version: 3
runtime: python
api_version: 1
handlers:
- url: /services/.*
script: main.py
main.py
#!/usr/bin/env python
import wsgiref.handlers
from pyamf.remoting.gateway.wsgi import WSGIGateway
def sayHello(name):
return "howdy " + name
services = {
'services.sayHello': sayHello
}
def main():
application = WSGIGateway(services)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
Flex 3 code (can be easily modified for Flex 4):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:RemoteObject id="ro" destination="services" endpoint="http://flexandthecloud.appspot.com/services/">
<mx:result>
l.text = event.result as String;
</mx:result>
</mx:RemoteObject>
<mx:TextInput id="ti"/>
<mx:Label id="l"/>
<mx:Button label="say hello" click="ro.sayHello(ti.text)"/>
</mx:Application>