【发布时间】:2018-04-18 00:35:34
【问题描述】:
我正在尝试用 Django 制作一个 Web 服务器来制作“鹦鹉机器人”。
我正在使用 python3.5 姜戈 apache2.4
我得到的错误:
Page not found (404)
Request Method: GET
Request URL: http://54.95.30.145/
Using the URLconf defined in bot.urls, Django tried these URL patterns, in this order:
^keyboard/
^message
The empty path didn't match any of these.
这是我的项目 bot/urls.py 代码。
from django.conf.urls import url, include
urlpatterns = [
url(r'',include('inform.urls')),
]
这是我的应用程序通知/urls.py 代码。
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^keyboard/',views.keyboard),
url(r'^message',views.message),
]
这是我的 inform/views.py 代码。
from django.http import JsonResponse
def keyboard(request):
return JsonResponse({
'type' : 'text',
})
def message(request):
message = ((request.body).decode('utf-8'))
return_json_str = json.loads(message)
return_str = return_json_str['contetn']
return JsonResponse({
'message': {
'text' : return_str
}
})
请帮帮我。
【问题讨论】:
标签: python django django-views webserver django-urls