我使用Django框架开发了一个webapp,并将其托管在数字海洋上。服务器应该从使用rails框架编写的客户端接收Json。
Django应用程序看不到Json,所以我想使用django-cors-headers https://github.com/ottoyiu/django-cors-headers,它要求我安装django-cors-headers,但是我已经承载了这个应用程序(即服务器)。
我的问题是(对不起我是新手)
django-cors-headers安装pip install django-cors-headers,可以使用PUTTY或Winscp?如果是,请告诉我怎么做?下面是服务器(views.py)的代码,我使用Django 1.9和python2.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)输出总是
{data: "json = JSON_DATA"}发布于 2016-04-16 07:23:21
如果您有shell访问权限,您当然应该能够使用pip安装pip应用程序或任何其他应用程序。但是,如果您的虚拟文件是只读的,您可以简单地将django-cors-headers中的文件复制到您的项目中。
https://stackoverflow.com/questions/36661249
复制相似问题