
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 France License.
I want to share a small snippet of code to upload a file to a remote server as a "multipart/form-data" . The function below gets two arguments. The server url ( ex: http://server.org/upload ) and a filename. First the filename encoded as a "form-data", then we use httplib to POST it to the server. Since httplib wants the host + path in separate stages, we have to parse the url using urlparse.
The receiving server must accept the data and return the location of the newly created resource. There are many snippet on the web, but I felt they were all incomplete or too messy.
a while ago I wrote about enabling the sqlite3 extension with storm . This is how you do it with the Django ORM. The collation is the same and all details are in the old post. The only tricky part is to establish the connection with cursor = connection.cursor() before calling the function to enable the extension.
Today I started learning how to write web forms in django. My quest was to write a simple search form where I could specify multiple criteria . Django is a very nice and flexible framework written in python and it is also reasonably well documented.
I don't feel writing much today. this is the code :
The tricky part was to understand how to re-display the view and to add a new field. This is easily accomplished in django using the formset class that allows to put display together more then one form. In this case the logic is simple.
Recent comments
51 weeks 16 hours ago
1 year 2 weeks ago
1 year 15 weeks ago
1 year 17 weeks ago
1 year 19 weeks ago
1 year 22 weeks ago
1 year 23 weeks ago
2 years 5 days ago
2 years 4 weeks ago