Django runserver, the header doesn't contain connection:keep-alive

536 views
Skip to first unread message

韦然

unread,
Dec 1, 2016, 4:42:38 AM12/1/16
to Django users
Dear all,

The current header is:

HTTP/1.0 200 OK

Date: Thu, 01 Dec 2016 08:33:29 GMT

Server: WSGIServer/0.1 Python/2.7.12

X-Frame-Options: SAMEORIGIN

Content-Type: text/xml



And the process code is :


from django.shortcuts import render

from django.http import HttpResponse

import xml.etree.ElementTree as ET

import re

# Create your views here.

from .forms import AddForm


ns = {'SOAP-ENV':'http://schemas.xmlsoap.org/soap/envelope/', \

      'SOAP-ENC':'http://schemas.xmlsoap.org/soap/encoding/', \

      'xsi':'http://www.w3.org/2001/XMLSchema-instance', \

      'xsd':'http://www.w3.org/2001/XMLSchema','cwmp':'urn:dslforum-org:cwmp-1-0'}

def index(request):

    if request.method == 'POST':

        #print('===================START=======================')

        #print(request.body)

        root = ET.fromstring(request.body)


        #print('===================END=======================')

        body = root.find('SOAP-ENV:Body', ns)

        inform = body.find('cwmp:Inform', ns)

        header = root.find('SOAP-ENV:Header', ns)

        idObj = header.find('cwmp:ID', ns)

        #print idObj.text

        #s = request.session()

        #print s

        return render(request, 'tools/cwmpInformResponse.html', {'cwmpID': idObj.text},content_type='text/xml')

    else:

        form = AddForm()

    return render(request, 'tools/index.html', {'form': form})

Avraham Serour

unread,
Dec 1, 2016, 5:33:20 AM12/1/16
to django-users

Don't use runserver fur production, use nginx with uwsgi


--
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/dc133975-8bf2-48fc-b32b-5868874f687e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

emepe

unread,
Dec 1, 2016, 8:32:09 AM12/1/16
to Django users
On Thursday, December 1, 2016 at 6:42:38 AM UTC-3, 韦然 wrote:
Dear all,

The current header is:

HTTP/1.0 200 OK

Date: Thu, 01 Dec 2016 08:33:29 GMT

Server: WSGIServer/0.1 Python/2.7.12

X-Frame-Options: SAMEORIGIN

Content-Type: text/xml



The docs states clearly that runserver is not for production, just for developing.  For a light webserver you could use nginx + gunicorn. The are several tutorials for this.

mikelpierre

韦然

unread,
Dec 1, 2016, 8:52:33 AM12/1/16
to Django users

Thanks. I will try other production servers.

在 2016年12月1日星期四 UTC+8下午9:32:09,emepe写道:
Reply all
Reply to author
Forward
0 new messages