Building a car-based GPS
In the previous section, we learned how to access Google Maps API on a Python program using the Flask library. Now we can combine our previous work about reading GPS on the Pololu Zumo robot.
After the program reads the GPS data on Arduino, we can send the GPS data to our web server (Flask framework).
Firstly, we modify gpsapp.py
to read the GPS data. You can read it directly from the GPS module or via the middleware app on the computer.
We will create a new routing /gps
which is implemented on the get_gps_data()
function. With this function, we will set the value "hardcoded". Basically, you should get lat_val
and long_val
from the GPS module. The get_gps_data()
function returns a JSON value. This makes our program, gspapp.py
, work as a RESTful server.
The following is a completed program on the gpsapp.py
file:
from flask import Flask from flask import render_template from flask import jsonify app = Flask(__name__) @app.route('/hello') defhello_world(): return 'Hello...