Building a web app for use of third party python package

42 views
Skip to first unread message

Enikő Regényi

unread,
Nov 21, 2017, 8:49:46 AM11/21/17
to Django users
Hello,

I would like to use Django for building a web application for use of a third party python package. 

This third party package uses a text file as input, and produces a bunch of text files as output (sorted in directories). 

I would like my website to take text/textfile from the user, and give an archive (.zip) back with all the output files. 

I went through the tutorial on the django website already, and made some progress, but my understanding is still shallow for this project.

Could someone point me to the best direction, or give tips on what bits of the documentation I should read to get my head around it as fast as possible?


Many thanks!

Eni

Derek

unread,
Nov 22, 2017, 10:17:49 AM11/22/17
to Django users
From what you have said, this is not too hard.

You need a basic view to handle the upload, which is in turn will make a call to the specialised method for processing of the file (and zip creation) before returning the result to the user.

A quick Google shows some relevant examples:

* https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html
* https://stackoverflow.com/questions/12881294/django-create-a-zip-of-multiple-files-and-make-it-downloadable

(Stack Overflow is, in general, a massive resource for Python/Django Q&A).

HTH

Enikő Regényi

unread,
Nov 25, 2017, 11:06:43 AM11/25/17
to Django users
Thanks, I managed to put together something that uploads input, processes the data and downloads the results. I bumped into a problem though: I would like to redirect the user AND download the file. Is that possible somehow? (I apologize if this is a trivial question,  I am new to django and fairly new to programming too) Can I concatenate HttpResponse objects somehow? I tried, but it errors out. 


Derek

unread,
Nov 26, 2017, 10:46:26 AM11/26/17
to Django users
I am not aware of such a way; I think HttpResponse does a single thing.  But you could create a page which embeds a link to the results file and redirect the user to that (I often find that  having an "outcomes" page with some explanation is attached is helpful to the user).  Like many similar sites (e.g. there is one that creates an MP3 from a YouTube Video), the link is only active for a while; you can run a cron job, or similar, in the background to remove the file after a while.
Reply all
Reply to author
Forward
0 new messages