Automatic print bill

Job ID: 34935762

Budget: ₹12,500 – ₹37,500 INR

from flask import Flask, render_template, jsonify, request, redirect, session
from models import *
from werkzeug.utils import secure_filename
folder_name="static"

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://postgres:username@localhost:5432/dbname"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"

db.init_app(app)
app.secret_key = 'anykeystring'


@app.route("/")
def index():
return render_template("index.html")

@app.route("/dashboard",methods=["POST"])
def dashboard():
unam = request.form.get("username")
pwd = request.form.get("password")
session['username']= unam
ulist=Users.query.filter_by(username=unam).first()
if ulist:
uid=ulist.userid
invList=Invoice.query.filter_by(userid=uid).all()
return render_template("dashboard.html",uname=unam,invList=invList, invDet=[], invSel=[])
else:
return render_template("index.html", msg='Wrong Credentials!!')


@app.route("/showInvoice/<int:invID>")
def showInvoice(invID):
unam=session['username']
ulist=Users.query.filter_by(username=unam).first()
invList=Invoice.query.filter_by(userid=ulist.userid).all()
invDet=InvoiceDet.query.filter_by(invoiceID=invID).all()
invSel=Invoice.query.filter_by(invoiceID=invID).first()
return render_template("dashboard.html",uname=unam,invList=invList, invDet=invDet, invSel=invSel)

@app.route("/logout")
def logout():
return render_template("index.html")
Related categories: Python Website Design Matlab and Mathematica