Want to upload a file to directory in google appengine using python
===

I am new to google appengine.
I want to upload a file to a directory instead of storing as blob.

main.py

    import cgi 
    import webapp2
    from google.appengine.api import users
    from google.appengine.ext.webapp.template \
        import render
    from os import path
    
    class MainHandler(webapp2.RequestHandler):
        def get(self):
            context={}
            tmpl = path.join(path.dirname(__file__), 'static/html/index.html')
            self.response.out.write(render(tmpl, context))
    
        def post(self):
           form_data = self.request.get('file')
           file_data = form_data
           f=open('static/html/'+form_data,'w')
           f.write(file_data)
           f.close
    
    
    
    routes=[
            (r'/', MainHandler),
            ]   
    app = webapp2.WSGIApplication(routes=routes,debug=True)

index.html

    > <html>
    >     <head><title>test</title></head>
    >     <body>hello
    >        <form id="addmovieform" action="/" method="post" ENCTYPE="multipart/form-data">
    >            <input type="file" name="file" >
    >            <input type="submit" name="submit">
    >        </form>
    >     </body>
    >         </html>


Error

> Traceback (most recent call last):   File
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 1536, in __call__
>     rv = self.handle_exception(request, response, e)   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 1530, in __call__
>     rv = self.router.dispatch(request, response)   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 1278, in default_dispatcher
>     return route.handler_adapter(request, response)   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 1102, in __call__
>     return handler.dispatch()   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 572, in dispatch
>     return self.handle_exception(e, self.app.debug)   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py",
> line 570, in dispatch
>     return method(*args, **kwargs)   File "/Users/saravase/test/main.py", line 33, in post
>     f=open('static/html/'+form_data,'w')   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
> line 589, in __init__
>     raise IOError('invalid mode: %s' % mode) IOError: invalid mode: w



please guide me ...



