Python is a general purpose language, not exactly made for web. There exists some embeddable PHP-like solutions, but in most Python web frameworks, you write Python and HTML (template) code separately.
For example in Django web framework you first write a view (view — you know — from that famous Model-View-Controller pattern) function:
def my_view(request, movie):
return render_to_template('my_view.html',
{'movie': settings.MEDIA_URL + 'flash.swf?' + movie})
And register it with URL dispatcher (in Django, there is a special file, called urls.py
):
...
url(r'/flash/(?P<movie>.+)$', 'myapp.views.my_view'),
...
Then a my_view.html
template:
...
<object classid="clsid:XXXXXXXXX-YYYY-ZZZZ-AAAA-BBBBBBBBBB" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="main" align="middle">
<param name="allowScriptAccess" value="all" />
<param name="flashvars" value= />
<param name="movie" value="{{ movie }}" />
<param name="loop" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#eeeeee" />
<embed src="{{ movie }}" loop="false" quality="high" bgcolor="#eeeeee" width="100%" height="100%" name="main" align="middle" allowScriptAccess="all" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
...
While this may seem like a lot of work for such a tiny task, when you have to write something bigger than simple value-substituting script, the framework pays back. For example, you may actually write a simple blog application in less than 100 lines of code. The framework will automatically take care of URL parsing (somehow like Apache's mod_rewrite for PHP), complex templating, database access, form generation, processing and validation, user authentication, debugging and so on.
There are a lot of different frameworks, each having its own good and bad sides. I recommend spending some time reading introductions and choosing one you like. Personally, I like Django, and had success with web.py. I've also heard good things about Pylons and TurboGears.
If you need something really simple (like in your example), where you don't need almost anything, you may just write small WSGI application, which then can be used, for example, with Apache's mod_python or mod_wsgi. It will be something like this:
def return_movie_html(environ, start_response):
request_uri = environ.get('REQUEST_URI')
movie_uri = request_uri[request_uri.rfind('/')+1:]
start_response('200 OK', [('Content-Type', 'text/html')])
return ['''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
...
<object ...>
<param name="allowScriptAccess" value="all" />
<param name="flashvars" value= />
<param name="movie" value="%(movie)s" />
<param name="loop" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#eeeeee" />
<embed src="%(movie)s" loop="false" ... />
</object>
...
</html>
''' % {'movie': movie_uri}]
To sum it up: without additional support libraries, Python web programming is somehow painful, and requires doing everything from the URI parsing to output formatting from scratch. However, there are a lot of good libraries and frameworks, to make job not only painless, but sometimes even pleasant :) Learn about them more, and I believe you won't regret it.