views:

221

answers:

1

Hi, I'm trying to redirect to a swf file because I need to embedd that in a fb:swf which wants its absolute path. When I handle the swf in url's somehow it doesn't work.

In url.py

(r'^flash/','lastproject.yofacebook.flashtest.flash'),

In flahstest.flash

def flash(request):
return render_to_response('as3.swf')

I want to open the swf on this url

http://testapp.varheroes.com/flash/

the fb:swf

<fb:swf 
 swfbgcolor="ffffff"  
 swfsrc='http://testapp.varheroes.com/flash/'
 width='620' height='530' />

The error I get

'utf8' codec can't decode bytes in position 5-6: invalid data
+1  A: 

render_to_response is used to render a template and send it as a response. I don't think your swf file is a template, so you should just return it directly:

return HttpResponse(open('as3.swf'))

But really you shouldn't be sending that file through Django at all, it should be served by whatever is serving the rest of your static files (CSS, JS etc).

Daniel Roseman
The thing is Django handle all my url's I just need to pass the swf's address to fb:swf ( wouldn't open('as3.swf')) open a new window?
Fahim Akhter
opening new window has nothing to do with HttpResponse, it is a browser action. Daniel is right - you should not be serving binary files like that, use apache nginx or whichever web server you are using to do static serving.
kibitzer
If my Django is serving all the url's of a certain prefix. Can I actually run away with static serving and bypass django url's?
Fahim Akhter