'How do i make the currentttime say hello when the information inside alarms is uequal to currenttime

Ok so i making a project for school with an alarm and i needed to make a flask server work with my python and i can quite get it to work, i get the information of alarms in the database or make it so when the time reaches a certain point if plays hello python code

from flask import Flask, render_template, url_for, request, redirect
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
import subprocess
from time import time
import sys

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///alarm.db'
db = SQLAlchemy(app)
def execute_unix(inputcommand):

  p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)

  (output, err) = p.communicate()

  return output


class alarmclock(db.Model):
   id = db.Column(db.Integer, primary_key=True)
   alarms = db.Column(db.String(200), nullable=False)
   date_created = db.Column(db.DateTime, default=datetime.utcnow)

   def __repr__(self):
       return '<Task %r>' % self.id

currenttime = datetime.now().strftime('%I:%M:%p')       
@app.route('/', methods=['POST', 'GET'])
def index():
   if request.method == 'POST':
       task_alarms = request.form['alarming']
       new_task = alarmclock(alarms=task_alarms)

       try:
           db.session.add(new_task)
           db.session.commit()
           while True:
               if (task_alarms == currenttime):
                   msg1 = 'espeak hello 2>>/dev/null'
                   execute_unix(msg1)
                   
                   return redirect('/')
       except:
           return 'There was an issue adding your task'

   else:
       tasks = alarmclock.query.order_by(alarmclock.date_created).all()
       return render_template('index.html', tasks=tasks)

@app.route('/delete/<int:id>')
def delete(id):
   task_to_delete = alarmclock.query.get_or_404(id)
   try:
       db.session.delete(task_to_delete)
       db.session.commit()
       return redirect('/')
   except:
       return 'There was a problem deleting that task'       
if __name__ == "__main__":
   app.run(debug=True, host = "0.0.0.0")

HTML code the task.alarms is what i think has all the information stored in it but i renamed it and i couldnt get what the user was inputting in the form

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   
  
</head>
<body>
 <title>Alarm Clock</title>
<h1>Alarm Clock Management</h1>
<p>Please enter your alarms in this format 01:08:PM</p>
<div class="alarms">
   
  
   <table>
       <tr>
           <th>Alarms</th>
           <th>Added</th>
           <th>Actions</th>
       </tr>
       {% for task in tasks %}
           <tr>
               <td>{{ task.alarms }}</td>
               <td>{{ task.date_created.date() }}</td>
               <td>
                   <a href="/delete/{{task.id}}">Delete</a>
                   
               </td>
           </tr>
       {% endfor %}
   </table>
  

   <div class="form">
       <form action="/" method="POST">
           <input type="text" name="alarming" id="alarming" placeholder="hh:mm:am/pm">
           <input type="submit" value="Add Alarm">
       </form>
   </div>
</div>  
</body>
</html>  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source