Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from flask import Flask, jsonify, render_template, request, redirect
from flask import Flask, jsonify, render_template, request, redirect #importing necessary libraries
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)
app = Flask(__name__) #initializing app

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db' #configure database
db = SQLAlchemy(app)


class BlogPost(db.Model):
class BlogPost(db.Model): #model for data table
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
Content = db.Column(db.Text, nullable=False)
Expand All @@ -19,8 +19,8 @@ class BlogPost(db.Model):
def __repr__(self):
return 'Blog post ' + str(self.id)


all_posts = [
#hard coded data array
all_posts = [
{
'title': 'Post1',
'Content': 'This is the content of post 1',
Expand All @@ -33,7 +33,7 @@ def __repr__(self):
}
]


#routes
@app.route('/', methods=['GET'])
def homepage():
return render_template('index.html')
Expand Down