POST method on localhost

43 views
Skip to first unread message

Allan

unread,
Sep 25, 2017, 5:06:16 PM9/25/17
to Django users
I've created a simple form for data upload.  I'm testing it through localhost and was wondering if this is realistic.  Web development is a new area for me so bare with me please if this is a laughable question.  I uploaded a 1GB file and it was uploaded and moved to a folder in my project in a matter of a few seconds.

def simple_upload(request):
   
if request.method =='POST' and request.FILES['myfile']:
        myfile
= request.FILES['myfile']
        fs
= FileSystemStorage()
        filename
= fs.save(myfile.name, myfile)
        uploaded_file_url
= fs.url(filename)
       
return render(request, 'simple_upload.html', {
           
'uploaded_file_url': uploaded_file_url
   
})

   
return render(request, 'simple_upload.html')

{% load static %}

{% block content %}
 
<form method="post" enctype="multipart/form-data">
   
{% csrf_token %}
   
<input type="file" name="myfile">
   
<button type="submit">Upload</button>
  </
form>

 
{% if uploaded_file_url %}
   
<p>File uploaded at: <a href="{{ uploaded_file_url }}">{{ uploaded_file_url }}</a></p>
 
{% endif %}

 
<p><a href="{% url 'dashboard' %}">Return to home</a></p>
{% endblock %}

Thanks!

Andréas Kühne

unread,
Sep 26, 2017, 3:37:58 AM9/26/17
to django...@googlegroups.com
Hi!

Yes that is realistic in the sense that it takes a couple of seconds to upload a 1GB file to localhost. It should take a small amount of time, because it is just copying the file (through django) to the directory you specified.

However uploading a 1 GB file to a web server on the Internet isn't feasible. It would probably take to long to upload and the connection would time out - unless you do a bit of magic on the connections. 

So, my question to you is what are you trying to accomplish? What is the purpose of your test?

Regards,

Andréas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bf2476d2-8470-4c91-8590-99ecc4f477de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Allan

unread,
Sep 26, 2017, 4:16:20 PM9/26/17
to Django users
Andreas my supervisor has asked me to determine the feasibility of using different frameworks for our web application.  Django seems nice to work with mainly because it is in Python and that gives us a lot.  Will different frameworks result in a huge difference in aspects such as data upload?  We are new to web development and at this stage we are doing research, and this would be a nice example to show.
Regards,

Andréas

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Andréas Kühne

unread,
Sep 26, 2017, 4:35:08 PM9/26/17
to django...@googlegroups.com
Hi again,

Different frameworks will probably not affect your upload speed. The web server (regardless of framework) is not the main problem, but the network speed, so regardless of which framework you choose in the end, it won't be the bottleneck. The thing is your web server is probably not even in the same country as you and the network connection will be the bottleneck for all frameworks. Not even if you are on the same network, the framework speed would be an issue.

But even so - you should probably think a bit more about design if you want to upload 1GB files - the web server itself will first of all be busy taking care of the files, and then you will need a very large harddrive to store the files?

I think you should probably look into more useful use cases and see if the framework is good for you in that regard.

Regards,

Andréas

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Allan

unread,
Sep 26, 2017, 4:57:44 PM9/26/17
to Django users
Would you have any recommendations on where to get started with this?  We were originally making a desktop application, but plans have shifted and I'm not very knowledgeable about everything web. 

Allan

Regards,

Andréas

Andréas Kühne

unread,
Sep 26, 2017, 5:18:32 PM9/26/17
to django...@googlegroups.com
I think most frameworks are pretty much the same today. 

What you should be looking for is something that you feel comfortable with. If you have been programming in java - look for a java framework. If you have been programming in python - look for a python framework. That being said, I personally prefer the python and django mindset of "batteries included" - there is just so much included in python and the django framework.

The next thing to consider is how you want the application itself to work - how your user should interact with the application - be that a standard MVC or if you want to create a single page application, more like a desktop application. 

And the final thing to consider is if you want to be able to create other applications that will connect to the server (for example mobile phone apps). 

All of this will help you evaluate what kind of framework and how the application should be created.

I would recommend that you get some experience with HTML / CSS / Javascript for all of the solutions - you will probably need it anyway.

Regards,

Andréas

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages