<p>我唯一熟悉的AMF库是<a href="http://pyamf.org/" rel="noreferrer">PyAMF</a>,到目前为止,它非常适合使用。以下是您对PyAMF问题的回答:</p>
<ul>
<li><p>我想你可以把它当作一个脚本来运行(你是说像CGI吗?),但IMO最简单的方法是专门为AMF请求设置应用服务器</p></li>
<li><p>最简单的方法是用纯python定义函数,PyAMF包装这些函数来序列化传入/传出的AMF数据</p></li>
<li><p>如果需要的话,可以通过套接字进行通信,但是同样,使用纯Python函数是最简单的;套接字的一个用途是保持开放的连接并将数据“推送”到客户端,请参见<a href="http://pyamf.org/wiki/BinarySocket" rel="noreferrer">this</a>示例</p></li>
</ul>
<p>下面是一个在<code>localhost:8080</code>上提供服务的三个简单AMF服务的示例:</p>
<pre><code>from wsgiref import simple_server
from pyamf.remoting.gateway.wsgi import WSGIGateway
## amf services ##################################################
def echo(data):
return data
def reverse(data):
return data[::-1]
def rot13(data):
return data.encode('rot13')
services = {
'myservice.echo': echo,
'myservice.reverse': reverse,
'myservice.rot13': rot13,
}
## server ########################################################
def main():
app = WSGIGateway(services)
simple_server.make_server('localhost', 8080, app).serve_forever()
if __name__ == '__main__':
main()
</code></pre>
<p>我绝对推荐PyAMF。查看<a href="http://pyamf.org/wiki/Examples" rel="noreferrer">examples</a>,看看它有什么功能,代码是什么样子的。在</p>