diff --git a/TO-DO App/Procfile b/TO-DO App/Procfile new file mode 100644 index 00000000..8001d1a5 --- /dev/null +++ b/TO-DO App/Procfile @@ -0,0 +1 @@ +web: gunicorn app:app \ No newline at end of file diff --git a/TO-DO App/__pycache__/app.cpython-39.pyc b/TO-DO App/__pycache__/app.cpython-39.pyc new file mode 100644 index 00000000..29c88af0 Binary files /dev/null and b/TO-DO App/__pycache__/app.cpython-39.pyc differ diff --git a/TO-DO App/app.py b/TO-DO App/app.py new file mode 100644 index 00000000..7a2f2a04 --- /dev/null +++ b/TO-DO App/app.py @@ -0,0 +1,63 @@ +from re import T +from flask import Flask, render_template, request, redirect +from flask_sqlalchemy import SQLAlchemy +from datetime import datetime + +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///todo.db" +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +db = SQLAlchemy(app) + +class Todo(db.Model): + sno = db.Column(db.Integer, primary_key=True) + title = db.Column(db.String(200), nullable=False) + desc = db.Column(db.String(500), nullable=False) + date_created = db.Column(db.DateTime, default=datetime.utcnow) + + def __repr__(self) -> str: + return f"{self.sno} - {self.title}" + + +@app.route("/", methods=['GET','POST']) +def hello_world(): + if request.method=='POST': + title = request.form['title'] + desc = request.form['desc'] + todo = Todo(title=title, desc=desc) + db.session.add(todo) + db.session.commit() + allTodo = Todo.query.all() + return render_template('index.html', allTodo=allTodo) + + +@app.route('/show') +def Products(): + allTodo = Todo.query.all() + print(allTodo) + return 'This Is Product Area' + + +@app.route('/Update/', methods=['GET','POST']) +def update(sno): + if request.method=='POST': + title = request.form['title'] + desc = request.form['desc'] + todo = Todo.query.filter_by(sno=sno).first() + todo.title = title + todo.desc = desc + db.session.add(todo) + db.session.commit() + return redirect("/") + + todo = Todo.query.filter_by(sno=sno).first() + return render_template('update.html', todo=todo) + + +@app.route('/delete/') +def delete(sno): + todo = Todo.query.filter_by(sno=sno).first() + db.session.delete(todo) + db.session.commit() + return redirect("/") +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/TO-DO App/requirements.txt b/TO-DO App/requirements.txt new file mode 100644 index 00000000..92a1f5c5 Binary files /dev/null and b/TO-DO App/requirements.txt differ diff --git a/TO-DO App/templates/base.html b/TO-DO App/templates/base.html new file mode 100644 index 00000000..1ecf8c5c --- /dev/null +++ b/TO-DO App/templates/base.html @@ -0,0 +1,39 @@ + + + + + + + + + + + Hello, world! + + + + {% block body %} + + {% endblock body %} + + \ No newline at end of file diff --git a/TO-DO App/templates/index.html b/TO-DO App/templates/index.html new file mode 100644 index 00000000..ee7ba7bb --- /dev/null +++ b/TO-DO App/templates/index.html @@ -0,0 +1,73 @@ +{% extends 'base.html' %} +{% block body %} + +
+

Add a Todo

+
+
+ + +
We'll never share your email with anyone else.
+
+
+ + +
+ + +
+
+ +
+

Your Todos

+ + {% if allTodo|length == 0 %} + + {% else %} + + + + + + + + + + + + + {% for todo in allTodo %} + + + + + + + + + + {% endfor %} + +
SnoTitleDescriptionTimeActions
{{loop.index}}{{todo.title}}{{todo.desc}}{{todo.date_created}} + Update + Delete + +
+ {% endif %} + + +
+ + + + + + + + +{% endblock body %} \ No newline at end of file diff --git a/TO-DO App/templates/update.html b/TO-DO App/templates/update.html new file mode 100644 index 00000000..2daed7a1 --- /dev/null +++ b/TO-DO App/templates/update.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} +{% block body %} + +
+

Update Your Todo

+
+
+ + +
We'll never share your email with anyone else.
+
+
+ + +
+ + +
+
+ + + + + + + + + + +{% endblock body %} \ No newline at end of file diff --git a/TO-DO App/todo.db b/TO-DO App/todo.db new file mode 100644 index 00000000..d674b024 Binary files /dev/null and b/TO-DO App/todo.db differ