Introduction
This tutorial shows you how to easily publish your PyAMF applications with the Apache 2 webserver and mod_wsgi. Mod_wsgi is an Apache module which can host any Python application which supports the Python WSGI interface. This was tested with Python 2.4.3, Apache 2.0.55, mod_wsgi 1.3 on Ubuntu 6.06.1 LTS.
This tutorial assumes you already installed the Apache webserver running (on 192.168.1.100). Flash applications will be able to access your PyAMF remoting gateway on http://192.168.1.100/flashservices/gateway.
Create a folder for your application:
mkdir /var/www/myApp
Create a startup file for your application in /var/www/myApp/startup.py:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import sys
import logging
sys.path.append('/usr/src/pyamf/')
sys.path.append('/var/www/myApp/')
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
)
from pyamf.remoting.gateway.wsgi import WSGIGateway
def echo(data):
return data
services = {
'echo': echo,
# Add other exposed functions here
}
application = WSGIGateway(services, logger=logging, debug=True)
|
Make sure your Apache user (www-data) has access to your application files.
This sample assumes you have a copy of the PyAMF source installed in /usr/src/pyamf but you can comment out line 4 if you installed PyAMF in your Python’s site-packages folder.
Create a new virtual host or modify an existing one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <VirtualHost 192.168.1.100:80>
ServerName example.server.com
DocumentRoot /var/www/myApp
CustomLog /var/log/apache2/myApp-access.log combined
ErrorLog /var/log/apache2/myApp-error.log
LogLevel warn
ServerSignature Off
# PyAMF gateway
WSGIScriptAlias /flashservices/gateway /var/www/myApp/startup.py
</VirtualHost>
|
That’s it! Your Adobe Flash Player and AMF clients will now be able to access your PyAMF application through http://192.168.1.100/flashservices/gateway.