From 1b9994b24dcf224fe3934c052e0addc0b9f9b5c9 Mon Sep 17 00:00:00 2001 From: Sami <80770093+beebObeb@users.noreply.github.com> Date: Sat, 22 Jul 2023 14:46:20 -0400 Subject: [PATCH 1/2] todo app done in flask --- readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29 From a1d7d8201bb5e7585bf0905bed22fce1ab2741b4 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 22 Jul 2023 22:30:48 +0300 Subject: [PATCH 2/2] Added a new mini project --- 021_Todo_APP/.idea/.gitignore | 3 ++ .../inspectionProfiles/profiles_settings.xml | 6 +++ 021_Todo_APP/.idea/misc.xml | 7 +++ 021_Todo_APP/.idea/modules.xml | 8 +++ 021_Todo_APP/.idea/todo-redone.iml | 10 ++++ 021_Todo_APP/main.py | 36 +++++++++++++ 021_Todo_APP/readme.md | 4 ++ 021_Todo_APP/templates/edit.html | 23 +++++++++ 021_Todo_APP/templates/index.html | 50 +++++++++++++++++++ 9 files changed, 147 insertions(+) create mode 100644 021_Todo_APP/.idea/.gitignore create mode 100644 021_Todo_APP/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 021_Todo_APP/.idea/misc.xml create mode 100644 021_Todo_APP/.idea/modules.xml create mode 100644 021_Todo_APP/.idea/todo-redone.iml create mode 100644 021_Todo_APP/main.py create mode 100644 021_Todo_APP/readme.md create mode 100644 021_Todo_APP/templates/edit.html create mode 100644 021_Todo_APP/templates/index.html diff --git a/021_Todo_APP/.idea/.gitignore b/021_Todo_APP/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/021_Todo_APP/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/021_Todo_APP/.idea/inspectionProfiles/profiles_settings.xml b/021_Todo_APP/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/021_Todo_APP/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/021_Todo_APP/.idea/misc.xml b/021_Todo_APP/.idea/misc.xml new file mode 100644 index 0000000..a0bf606 --- /dev/null +++ b/021_Todo_APP/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/021_Todo_APP/.idea/modules.xml b/021_Todo_APP/.idea/modules.xml new file mode 100644 index 0000000..867cff5 --- /dev/null +++ b/021_Todo_APP/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/021_Todo_APP/.idea/todo-redone.iml b/021_Todo_APP/.idea/todo-redone.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/021_Todo_APP/.idea/todo-redone.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/021_Todo_APP/main.py b/021_Todo_APP/main.py new file mode 100644 index 0000000..fc575b5 --- /dev/null +++ b/021_Todo_APP/main.py @@ -0,0 +1,36 @@ +from flask import Flask, request, render_template, redirect, url_for +from flask_bootstrap import Bootstrap + +#create the app +app = Flask(__name__) +bootstrap = Bootstrap(app) + +#the database +todos = [] +#routes +@app.route('/') +def index(): + return render_template('index.html', todos=todos) +@app.route('/add', methods=['POST']) +def add(): + task = request.form['todo'] + todos.append({"task":task, "done":False}) + return redirect(url_for('index')) +@app.route('/remove/', methods=['GET']) +def remove(index): + del todos[index] + return redirect(url_for('index')) + +@app.route('/edit/', methods=['GET', 'POST']) +def edit(index): + if request.method == 'GET': + todo = todos[index] + return render_template('edit.html', todo=todo, index=index) + else: + task = request.form['todo'] + todo = todos[index] + todo['task'] = task + return redirect(url_for('index')) + +#run the app +app.run(debug=True) diff --git a/021_Todo_APP/readme.md b/021_Todo_APP/readme.md new file mode 100644 index 0000000..377d785 --- /dev/null +++ b/021_Todo_APP/readme.md @@ -0,0 +1,4 @@ +[ A Todo App Done with Flask ] + +It is written using the microframework Flask, and Bootstrap +enjoy ! diff --git a/021_Todo_APP/templates/edit.html b/021_Todo_APP/templates/edit.html new file mode 100644 index 0000000..bc5aa04 --- /dev/null +++ b/021_Todo_APP/templates/edit.html @@ -0,0 +1,23 @@ +{% extends "index.html" %} + +{% block content %} + +
+
+
+
+

Edit

+
+
+ + + + +
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/021_Todo_APP/templates/index.html b/021_Todo_APP/templates/index.html new file mode 100644 index 0000000..f683769 --- /dev/null +++ b/021_Todo_APP/templates/index.html @@ -0,0 +1,50 @@ +{% extends "bootstrap/base.html" %} +{% block title %} todo {% endblock %} + +{% block content %} +
+
+
+

Tasks

+
    + {% if not todos %} +
  • No Tasks to Display
  • + {% else %} + {% for todo in todos %} +
    + + + +
  • +
    + {{ todo['task'] }} + + +
    +
  • +
    + {% endfor %} + {% endif %} +
+
+
+
+
+ +
+
+
+
+
+ + + + +
+
+
+
+
+ + +{% endblock %} \ No newline at end of file