Reputation: 11
I developed a webapp using Django framework and hosted it on Digital Ocean. The server is supposed to receive a Json from a client written using Ruby rails framework.
The Django app cannot see the Json and so I want use django-cors-headers
https://github.com/ottoyiu/django-cors-headers which require me to install django-cors-headers
, but I have already hosted the app (i.e. the server).
My questions are ( sorry I am newbie)
django-cors-headers
using the pip install django-cors-headers
on the server host computer at Digital Ocean using may be PUTTY or Winscp? If yes, pls how do i do it?Below is the code for the server (views.py) and I am using Django 1.9 and python 2.7.6
from django.shortcuts import render
from django.http import HttpResponse
from django.http import JsonResponse
import json
def qucserver (request):
if request.method == 'POST':
print request.body
jsdata = json.loads(request.body)
reply = {"data": jsdata}
return JsonResponse ( reply )
else:
message = 'You submitted an empty form.'
reply = {"Error": message}
return JsonResponse (reply)
The output is always
{data: "json = JSON_DATA"}
Upvotes: 0
Views: 205
Reputation: 53774
If you have shell access you certainly ought to be able to install the django-cors-headers
app or any other app using pip
. However if your virtualenv is read only, you can simply copy the files from django-cors-headers into your project.
Upvotes: 1