+export FLASK_APP=app.py
+export FLASK_ENV=development
+# run in debug mode (auto reload on code change)
+export FLASK_DEBUG=1
+flask run --host=0.0.0.0
+```
diff --git a/app.py b/app.py
old mode 100644
new mode 100755
index 3e708f5..e5b55f7
--- a/app.py
+++ b/app.py
@@ -1,88 +1,66 @@
-import socket
-import sqlite3
-import secrets
-import dbChecker
-from datetime import datetime
-from flask import Flask, render_template, redirect
+from flask import Flask, render_template, request, redirect, url_for, flash
+from flask_sqlalchemy import SQLAlchemy
+from flask_wtf.csrf import CSRFProtect
app = Flask(__name__)
-app.secret_key = secrets.token_urlsafe(32)
+# /// = relative path, //// = absolute path
+app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
+app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
+app.config['SECRET_KEY'] = 'dev-secret-key-change-in-production'
+db = SQLAlchemy(app)
+csrf = CSRFProtect(app)
-def currentDate():
- return datetime.now().strftime("%d.%m.%y")
+class Todo(db.Model):
+ id = db.Column(db.Integer, primary_key=True)
+ title = db.Column(db.String(100))
+ complete = db.Column(db.Boolean)
+with app.app_context():
+ db.create_all()
-def currentTime():
- return datetime.now().strftime("%H:%M")
-
-
-@app.route("/")
+@app.get("/")
def index():
- connection = sqlite3.connect("todos.db")
- cursor = connection.cursor()
- cursor.execute("select * from todos")
- todos = cursor.fetchall()
- return render_template("/index.html", todos=todos)
-
-
-@app.route("/add/{{todo[0]}}
-+ This is a simple todo app built with Flask and SQLAlchemy. It uses the Semantic UI framework for styling. +
+ +Here you can open the list of Todos: link
+
- {{todo[3]}}
- {{todo[2]}}
-
{{todo.id }} | {{ todo.title }}
+ + {% if todo.complete == False %} + Not Complete + {% else %} + Completed + {% endif %} + + + +{{todo.id }} | {{ todo.title }}
+ + {% if todo.complete == False %} + Not Complete + {% else %} + Completed + {% endif %} + + + +