From b203622ad5bf8b0bcc3d35ac14460d4abd63db21 Mon Sep 17 00:00:00 2001 From: xemeds Date: Mon, 20 Jul 2020 14:55:19 +0000 Subject: [PATCH] Added the database --- tiny0/database.db | Bin 0 -> 12288 bytes tiny0/models.py | 10 ++++++---- tiny0/routes.py | 4 ++-- tiny0/token.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 tiny0/database.db diff --git a/tiny0/database.db b/tiny0/database.db new file mode 100644 index 0000000000000000000000000000000000000000..d19529601034b1b3d61c20de1be7a869f484156c GIT binary patch literal 12288 zcmeI#K}*9h6bJC66J>=lp@&@`1)&9zq8E?W8nmotF1F%MW6}!6xyh`st9~`V*j|T~ z?ciO;|Iwrg?=_HLPw#%1lvP2`^Tq3=qBC(Qq!brKLI{gTi$@dney`c^TW+lXT3X^H z`tESn>XPWb@q~Z?1Rwwb2tWV=5P$##AOHaf{6hh4?e~rx`CiWQVp%T7nMuag{H2)j zq7@kxriwBh4>LuvzEY3mZWg&T(ByKdOWyh`|Fa_xdX6K%WHou37M$Y8`Z*{KFB8?& z+wC&vGgEb~4Cz5iI!lscvfJx}=pi)GO=!Gxe=GU1nEs|tgCN+>-kJC|G$ZP(5qV|q z+kV}fbJLH200bZa0SG_<0uX=z1Rwwb2tZ(m1?>86=>K>4594YOfB*y_009U<00Izz K00bZa0U=hURzr;d literal 0 HcmV?d00001 diff --git a/tiny0/models.py b/tiny0/models.py index f3c14c9..f40229d 100644 --- a/tiny0/models.py +++ b/tiny0/models.py @@ -1,7 +1,9 @@ from tiny0 import db -''' +class URL(db.Model): + id = db.Column(db.Integer, primary_key=True) + token = db.Column(db.String(8), index=True, unique=True, nullable=False) + url = db.Column(db.String(2000), nullable=False) -Declaration of models - -''' + def __repr__(self): + return f"'{self.id}' '{self.token}' '{self.url}'" diff --git a/tiny0/routes.py b/tiny0/routes.py index 7a34f1a..0f7bb1b 100644 --- a/tiny0/routes.py +++ b/tiny0/routes.py @@ -1,7 +1,7 @@ from flask import render_template, redirect, request, url_for -from tiny0 import app +from tiny0 import app, db from tiny0.forms import URLForm -#from tiny0.models import URLs +from tiny0.models import URL #from token import gen_valid_token # Index Page diff --git a/tiny0/token.py b/tiny0/token.py index d489b0d..29420ab 100644 --- a/tiny0/token.py +++ b/tiny0/token.py @@ -1,4 +1,4 @@ -#from tiny0.models import URLs +#from tiny0.models import URL from secrets import choice '''