Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4821

Python • Re: Raspberry Pi pill dispenser using servos 30

$
0
0
I need to change links to buttons!!! Then I need delete add pill form pill schedule.
I would like to am/mp to view schedule

Code:

import sqlite3from flask import Flask, render_templateapp = Flask(__name__)# Function to fetch pill schedule from the databasedef fetch_pill_schedule():    conn = sqlite3.connect('pill_database.db')    c = conn.cursor()    c.execute('SELECT * FROM pills')    pill_schedule = c.fetchall()    conn.close()    return pill_schedule@app.route('/')def index():    return render_template('index.html')@app.route('/view_schedules')def view_schedules():    pill_schedule = fetch_pill_schedule()    return render_template('view_schedule.html', pill_schedule=pill_schedule)@app.route('/add_pill')def add_pill():    return render_template('add_pill.html')if __name__ == '__main__':    app.run(debug=True, host='0.0.0.0')

Code:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Pill Dispenser</title></head><body>    <h1>Pill Dispenser</h1>    <p>Click below to view schedules:</p>    <a href="/view_schedules">View Schedules</a>    <p>Click below to add a new pill:</p>    <a href="/add_pill">Add Pill</a></body></html>

Code:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Add Pill</title></head><body>    <h1>Add Pill</h1>    <form method="POST">        <label for="pill_name">Pill Name:</label><br>        <input type="text" id="pill_name" name="pill_name" required><br>        <label for="schedule_time">Schedule Time:</label><br>        <input type="time" id="schedule_time" name="schedule_time" required><br><br>        <button type="submit">Add Pill</button>    </form>    <p><a href="/view_schedules">View Schedules</a></p>    <p><a href="/">Back to Home</a></p></body></html>

Statistics: Posted by bob5731 — Wed Mar 27, 2024 11:43 pm



Viewing all articles
Browse latest Browse all 4821

Trending Articles