Hi all,
I am having an issue HTTP POSTing GPS data from my Arduino to the my Django server so I can save that data in my database. The Arduino Libraries are already set up, and all I need to do is input the host, port, resource, and data i want to send. What I have is:
host [] = "marcoprouve.pythonanywhere.com";
port = 80;
resource [] = "/sensors4G/sensor_log";
data [] = "\"Name\" = \"John\"";
My project (sensorLogger) urls.py looks like:
from django.conf.urls import include, url
from django.contrib import admin
import sensors4G.views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', sensors4G.views.index, name="index"),
url(r'^sensors4G/', include('sensors4G.urls')),
]
My app (sensors4G) urls.py looks like:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^sensor_log/', views.sensor_log, name='sensor_log'),
]
Finally my App (sensors4G) views.py looks like:
from django.shortcuts import render
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_protect, csrf_exempt
def index(request):
return HttpResponse("Hello, you're at the sensors4G index!")
@csrf_exempt
def sensor_log(request):
return HttpResponse("Hello, you're at sensors4G sensor_log!")
The reason my views look empty is because I am currently just testing to see if the POST reaches the URL and gets a response. When I try to Post to the server I get this response:
Http code: 404 Server response: Server: openresty/1.9.15.1
If you have a solution or can provide me with any advice on how to better approach POSTing from an Arduino to my Django Server I would greatly appreciate it. Thanks!