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 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29