示例#1
0
from flask import render_template

from webapp import app
from webapp.route import bp
from webapp.database import setup

#

app.register_blueprint(bp)
setup()


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


@app.errorhandler(404)
def pagenotfound(error):
    return render_template('error.html')
示例#2
0
from webapp import app
from flask import Blueprint, render_template

home = Blueprint('home', __name__)

@home.route('/', defaults={'path': ''})
@home.route('/<path:path>')
def catch_all(path):
    return render_template("index.html")


app.register_blueprint(home, url_prefix='/')
示例#3
0
    if request.method == 'POST':
        form.process(request.form, username='', password='')
        if form.validate():
            user = db.session.query(User) \
                    .filter_by(username=request.form['username'],
                        password=User.encode(request.form['username'],
                                             request.form['password'])) \
                    .first()
            if user:
                login_user(user)
                flash("Logged in successfully.")
                return redirect(next_url)
            else:
                flash('Invalid username/password.', 'error')

    description = 'Coin.Box is a POS Software'
    keywords = ['pos', 'point-of-sale', 'software']
    return render_template("auth/login.html", form=form,
                meta={'description': description, 'keywords': keywords})


@bp.route("/logout")
@login_required
def logout():
    logout_user()
    flash('You have been logged out')
    return redirect(url_for("index"))

app.register_blueprint(bp, url_prefix='/users')
示例#4
0
bp = Blueprint("documentation", __name__, template_folder="templates")


@bp.route("/")
def index():
    description = "Coin.Box is a POS Software"
    keywords = ["pos", "point-of-sale", "software"]
    return render_template(
        "documentation.html",
        template="docs/index.md",
        title="Index",
        meta={"description": description, "keywords": keywords},
    )


@bp.route("/<path:slug>/")
def page(slug):
    description = "Coin.Box is a POS Software"
    keywords = ["pos", "point-of-sale", "software"]

    template_name = "docs/" + slug + ".md"
    return render_template(
        "documentation.html",
        template=template_name,
        title=slug.replace("-", " ").title(),
        meta={"description": description, "keywords": keywords},
    )


app.register_blueprint(bp, url_prefix="/docs")
示例#5
0
     SQLAlchemySessionUserDatastore
from webapp import app
from webapp.config import config as app_config
from webapp.database import db_session, engine
from webapp.models import User, Role
from webapp.apis.upload import upload_api
from webapp.apis.chart import chart_api
from webapp.apis.jobs import jobs_api
from webapp.utils import generate_master_table_name
import click
import s3fs

# Setup Flask-Security
user_datastore = SQLAlchemySessionUserDatastore(db_session, User, Role)
security = Security(app, user_datastore)
app.register_blueprint(upload_api)
app.register_blueprint(chart_api)
app.register_blueprint(jobs_api)


@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
@login_required
def home(path):
    return render_template('index.html')


@app.route('/health-check')
def health_check():
    return 'OK!'