Python中文
首页
教程
问答
标签
搜索
登录
注册
无法从端点检索数据
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我已经为Django集成安装了<a href="http://chatterbot.readthedocs.io/en/stable/django/index.html" rel="nofollow noreferrer">Chatterbot</a>。我遵循简易教程的每一步,使它的端点是:<code>http://127.0.0.1:8000/chatterbot/</code>我下一步做的是尝试与该端点通信,看看我是否会得到任何结果。因此,我提出了如下Ajax请求:</p> <pre><code>var query = {"text": "My input statement"}; $.ajax({ type: 'POST', url: "http://127.0.0.1:8000/chatterbot/", data: JSON.stringify(query), contentType: 'application/json', success: function (data) { console.log(data); } }); </code></pre> <p>但是,在控制台中返回的是:<code>POST http://127.0.0.1:8000/chatterbot/ 403 (Forbidden)</code>,在运行服务器时在cmd提示符中返回的是:</p> <blockquote> <p>csrf: WARNING - Forbidden (CSRF token missing or incorrect.): /chatterbot/ [29/Mar/2018 02:16:43] "POST /chatterbot/ HTTP/1.1" 403 2502</p> </blockquote> <p>为什么我会犯这个错误?如何修复它以便接收来自端点的回叫?你知道吗</p> <p><strong>查看此页:</strong></p> <pre><code>def IndexView(request): latest_questions = Questions.objects.all().order_by("-date_published")[:5] popular_questions = Questions.objects.all().order_by("-num_replies")[:5] return render(request, 'core/index.html', {'latest_questions': latest_questions, 'popular_questions': popular_questions }) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>如果您不想使用CSRF令牌,只需在代码上方添加这个。你知道吗</p> <pre><code>from django.views.decorators.csrf import csrf_exempt @csrf_exempt def IndexView(request): # your code </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何重塑数组、迭代列的所有行并将重塑后的数组分配给新列?Python/Pandas/Numpy
6 回答
如何重塑数组的形状?
7 回答
如何重塑文本数据以适应keras的LSTM模型
5 回答
如何重塑未对齐的数据集,并使用numpy丢弃剩余数据?
6 回答
如何重塑此数据以使用绘图
6 回答
如何重塑此数据帧?
8 回答
如何重塑此数据集以适应RNN
1 回答
如何重塑没有列的数组?
8 回答
如何重塑测试数据帧,使其维数与训练和预测工作中使用的维数相同?
3 回答
如何重塑系列以在StandardScaler中使用它
9 回答
如何重塑线性回归的数据
6 回答
如何重塑线性回归的数据?
5 回答
如何重塑表格?
9 回答
如何重塑要堆叠的重复宽数据帧?
1 回答
如何重塑输入以放入二维层?
8 回答
如何重塑输入神经网络的三通道数据集
6 回答
如何重塑这个numpy数组
4 回答
如何重塑这个numpy数组以排除“额外维度”?
9 回答
如何重塑这个numpy阵列?
9 回答
如何重塑这个数据帧
7 回答