Commit 809ec1d5 authored by Nirmal M.D.S's avatar Nirmal M.D.S

created getTask.py

parent c7733665
from flask import Flask, render_template
import mysql.connector
app = Flask(__name__)
# Define your MySQL database connection parameters
db_config = {
'host': 'localhost',
'user': 'root',
'password': '',
'database': 'rptestdb',
}
# Define a function to fetch data from the database
def get_assigned_tasks():
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor()
cursor.execute('SELECT * FROM assignedtask')
tasks = cursor.fetchall()
conn.close()
return tasks
@app.route('/')
def index():
tasks = get_assigned_tasks()
# Print the data to the console
for task in tasks:
print("Task:", task) # Print each task
print("Number of tasks:", len(tasks)) # Print the number of tasks
return render_template('assigntask.html', tasks=tasks)
if __name__ == '__main__':
app.run(debug=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment