【发布时间】:2020-10-25 22:38:18
【问题描述】:
我是 Django 新手,我想制作一个简单的 RESTful API,它会在从邮递员调用它时以 JSON 格式返回 Python 字典。我已经设置了我的项目文件夹并安装了 RestfulAPI 框架,还配置了我的 settings.py 例如, 在 dictionary.py 我有以下代码
dataDictionary = {
'hello': 'World',
'geeks': 'forgeeks',
'ABC': 123,
456: 'abc',
14000605: 1,
'list': ['geeks', 4, 'geeks'],
'dictionary': {'you': 'can', 'send': 'anything', 3: 1}
}
我想通过使用 POST 方法输入 URL http://127.0.0.1:8000/getdata/ 从 Postman 调用它时返回这个字典。 我附上了 Django APP VIEW 图片。 Django_APP
【问题讨论】: