I'm trying to make a web server with Django for making "parrot bot".
I'm using python3.5 Django apache2.4
The error I'm getting :
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.
This is my project bot/urls.py code.
from django.conf.urls import url, include
urlpatterns = [
url(r'',include('inform.urls')),
]
This is my app inform/urls.py code.
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^keyboard/',views.keyboard),
url(r'^message',views.message),
]
This is my inform/views.py code.
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
}
})
Please help me.
It error is nothing but you didn't define any url patterns
for your root
address (http://54.95.30.145/
).
To solve this, add a url pattern for home/root address as below in project bot/urls.py
from django.conf.urls import url, include
def root_view(request):
return JsonResponse({"message": "This is root"})
urlpatterns = [
url(r'^$', root_view),
url(r'', include('inform.urls')),
]