diff --git a/.gitignore b/.gitignore
index ede80b8..2be620c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
# created by virtualenv automatically
*
+bin/
diff --git a/README.md b/README.md
index 7f92142..20f0de3 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,27 @@
# python-flask-Web-APP
-### This is a web application made with python-Flask, and SQLLITE3 used as backend.
+### This is a Web Application made with python-Flask, and SQLLITE3 used as backend.
-### Project View.
+### Project View
+
+## Use Cases
+1. User can add any number of blogpost.
+2. User an also edit their blog
+3. User can also delete posts by clicking on red button.
Hello I am Kavyansh. Welcome to my blog. Here I post my thoughts like my experience in colleges and now in corporate. I also post technical contents there.

+
+
+
+### How to Run.
+
+ -> Clone this repo
+ -> Install dependepcies
+ -> Run "app.py"
+
+
+
+
diff --git a/app.py b/app.py
index 015cfa9..d35fba1 100644
--- a/app.py
+++ b/app.py
@@ -1,4 +1,4 @@
-from flask import Flask,jsonify, render_template, request,redirect
+from flask import Flask, jsonify, render_template, request, redirect
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
@@ -7,40 +7,51 @@
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'
db = SQLAlchemy(app)
+
class BlogPost(db.Model):
id = db.Column(db.Integer, primary_key=True)
- title = db.Column(db.String(100), nullable = False)
- Content = db.Column(db.Text, nullable = False)
- Author = db.Column(db.String(20), nullable = False, default = 'Unknown')
- date_posted = db.Column(db.DateTime, nullable = False, default= datetime.utcnow)
+ title = db.Column(db.String(100), nullable=False)
+ Content = db.Column(db.Text, nullable=False)
+ Author = db.Column(db.String(20), nullable=False, default='Unknown')
+ date_posted = db.Column(db.DateTime, nullable=False,
+ default=datetime.utcnow)
def __repr__(self):
return 'Blog post ' + str(self.id)
+
all_posts = [
{
'title': 'Post1',
- 'Content':'This is the content of post 1',
- 'Author':'kavyansh'
+ 'Content': 'This is the content of post 1',
+ 'Author': 'kavyansh'
},
{
'title': 'Post2',
- 'Content':'This is the content of post 2',
+ 'Content': 'This is the content of post 2',
# 'Author': ''
}
]
-@app.route('/', methods =['GET'])
+
+@app.route('/', methods=['GET'])
def homepage():
return render_template('index.html')
+
+@app.route('/aboutus', methods=['GET'])
+def aboutpage():
+ return render_template('about.html')
+
+
@app.route('/contactus', methods=['GET'])
def contact():
- return render_template('contact.html')
+ return render_template('contact.html')
-@app.route('/posts/newposts', methods=['GET','POST'])
+
+@app.route('/posts/newposts', methods=['GET', 'POST'])
def addPosts():
- if request.method == 'POST':
+ if request.method == 'POST':
post_title = request.form['title']
post_content = request.form['Content']
post_author = request.form['Author']
@@ -48,7 +59,8 @@ def addPosts():
if post_author == '':
post_author = 'Unknown'
- new_post = BlogPost(title=post_title, Content=post_content, Author=post_author)
+ new_post = BlogPost(
+ title=post_title, Content=post_content, Author=post_author)
db.session.add(new_post)
@@ -57,14 +69,12 @@ def addPosts():
return redirect('/posts')
else:
- return render_template('add_posts.html')
+ return render_template('add_posts.html')
-
-
-@app.route('/posts',methods =['GET', 'POST'])
+@app.route('/posts', methods=['GET', 'POST'])
def posts():
- if request.method == 'POST':
+ if request.method == 'POST':
post_title = request.form['title']
post_content = request.form['Content']
@@ -73,7 +83,8 @@ def posts():
if post_author == '':
post_author = 'Unknown'
- new_post = BlogPost(title=post_title, Content=post_content, Author=post_author)
+ new_post = BlogPost(
+ title=post_title, Content=post_content, Author=post_author)
db.session.add(new_post)
@@ -81,15 +92,12 @@ def posts():
return redirect('/posts')
-
else:
all_posts = BlogPost.query.order_by(BlogPost.date_posted).all()
- return render_template('posts.html', posts = all_posts)
+ return render_template('posts.html', posts=all_posts)
-
-
-@app.route('/posts/delete/About Us
+
+Welcome to My Blog..
+ Author : kavyansh
+
+
+ Back
+
Connect with me on linkedin.
++ LinkedIn + » +
-{% endblock %} \ No newline at end of file +{% endblock %}