summaryrefslogtreecommitdiff
path: root/app/routes.py
diff options
context:
space:
mode:
authorblendoit <blendoit@gmail.com>2020-02-03 02:06:13 -0800
committerblendoit <blendoit@gmail.com>2020-02-03 02:06:13 -0800
commitb5b8b9bdbcc7f83d4a3e23b3e03e33cd08ee10a3 (patch)
tree1afe9e2c2ca37dc56627e9c242b8d67ed53d98fd /app/routes.py
parentcf900c5f560834b033dd5ee54df43fa84d1d75fe (diff)
Homepage load animations 2.
Diffstat (limited to 'app/routes.py')
-rw-r--r--app/routes.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/app/routes.py b/app/routes.py
index e520602..67b9359 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -16,6 +16,7 @@ Personal imports:
These are used to avoid cluttering this file with
placeholder data for posts' content.
"""
+from datetime import datetime
from flask import Flask, render_template, flash, redirect, url_for
from forms import RegistrationForm, LoginForm
from flask_sqlalchemy import SQLAlchemy
@@ -26,11 +27,37 @@ from placeholder_messages import messages
app = Flask(__name__)
app.config['SECRET_KEY'] = 'Scooby_Lu,_where_are_you?'
-app.config['SQLALCHEMY_DATABASE_URI'] = 'mariadb:///site.db'
-
+app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)
+class Alias(db.Model):
+ id = db.Column(db.Integer, primary_key=True)
+ username = db.Column(db.String(20), unique=True, nullable=False)
+ email = db.Column(db.String(120), unique=True, nullable=False)
+ image_file = db.Column(db.String(20),
+ nullable=False,
+ default='default.png')
+ password = db.Column(db.String(60), nullable=False)
+ posts = db.relationship('Post', backref='author', lazy=True)
+
+ def __repr__(self):
+ return f"Alias('{self.username}','{self.email}','{self.image_file}' )"
+
+
+class Post(db.Model):
+ id = db.Column(db.Integer, primary_key=True)
+ title = db.Column(db.String(100), nullable=False)
+ date_posted = db.Column(db.DateTime,
+ nullable=False,
+ default=datetime.utcnow)
+ content = db.Column(db.Text, nullable=False)
+ user_id = db.Column(db.Integer, db.ForeignKey('alias.id'), nullable=False)
+
+ def __repr__(self):
+ return f"Post('{self.title}', '{self.date_posted}')"
+
+
@app.route("/")
@app.route("/home")
def home():
Copyright 2019--2024 Marius PETER