Created
August 6, 2018 13:56
-
-
Save rupesh2017/a9a5e748cb8e19bc15fd3c23e4db713c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask,render_template,request,session | |
from flask_session import Session | |
from werkzeug.security import generate_password_hash, check_password_hash | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
engine = create_engine(os.getenv("DATABASE_URL")) | |
db = scoped_session(sessionmaker(bind=engine)) | |
app = Flask(__name__) | |
app.config["SESSION_PERMANENT"]=False | |
app.config["SESSION_TYPE"]="filesystem" | |
Session(app) | |
@app.route("/",methods =["GET","POST"]) | |
def index(): | |
if session.get("notes") is None: | |
session["notes"]=[] | |
if request.method == "POST": | |
note = request.form.get("note") | |
session["notes"].append(note) | |
return render_template("index.html",notes= session["notes"]) | |
@app.route("/about",methods =["GET","POST"]) | |
def about(): | |
if session.get("notes2") is None: | |
session["notes2"]=[] | |
if request.method == "POST": | |
note = request.form.get("note2") | |
session["notes2"].append(note) | |
return render_template("index2.html",notes= session["notes2"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment