Hardware Reference
In-Depth Information
In the Python script that launches the web server, we read the submitted
parameters and write them to a CSV file along with a timestamp:
@app.route('/', methods=['POST'])
def record():
#record all the data from the form
bloodPressure=request.form['BloodPressure']
SpO2=request.form['SpO2']
pulse=request.form['pulse']
#before writing to a csv file, log time stamps
date = datetime.today().strftime('%Y-%m-%d')
time = datetime.now().strftime('%H:%M:%S')
logfile = open('static\\comments.csv', 'a')
logfile.write(",".join([date,time,bloodPressure, SpO2,
pulse,'\n']))
logfile.close()
return render_template('form_action.
html',date=date,time=time,
bloodPressure=bloodPressure, SpO2=SpO2,pulse=pulse
Once we're done writing to the CSV file, we redirect the submitted form
to a page that displays the recorded values along with the timestamp
(as shown in the following figure):
The page displayed after the results are recorded
2.
It is possible to view the recorded data on the web page by reading the CSV file.
We leave this for you to igure out (look at this topic's website for the answer).
Objective complete - mini debriefing
We built a simple Flask-framework-based web server to record vital health parameters
using Raspberry Pi. It is possible to e-mail the data at regular intervals using the smtp
module in Python.
 
Search WWH ::




Custom Search