Newer
Older
from flask import Blueprint, render_template, request, redirect
from config import url_for2
home_blueprint = Blueprint('home', __name__, url_prefix='/')
@home_blueprint.route('')
def home():
return render_template('index.html')
@home_blueprint.route('/hello/<name>')
def hello(name: str):
return "Hello, " + name
# Example CRUD route
@home_blueprint.route('/entities', methods=['GET', 'POST'])
def entities():
if request.method == "GET":
try:
rows = ""
for e in db.session.query(Entity).all():
rows += str(e) + "<br>"
return rows
except:
name = request.form.get('name')
age = request.form.get('age')
db.session.commit()
return redirect(url_for2('.entities'))
except: