Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
comb:webapp0 [2014/08/02 07:53] alfred [Relationships with SQLAlchemy] |
comb:webapp0 [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 139: | Línea 139: | ||
| db = SQLAlchemy() | db = SQLAlchemy() | ||
| + | </code> | ||
| + | <code python> | ||
| # apps.members.models | # apps.members.models | ||
| from apps.shared.models import db | from apps.shared.models import db | ||
| Línea 145: | Línea 147: | ||
| # TODO: Implement this. | # TODO: Implement this. | ||
| pass | pass | ||
| + | </code> | ||
| + | <code python> | ||
| # apps.reporting.members | # apps.reporting.members | ||
| from flask import render_template | from flask import render_template | ||
| Línea 153: | Línea 157: | ||
| members = Member.filter(1==1).all() | members = Member.filter(1==1).all() | ||
| return render_template("report.html", members=members) | return render_template("report.html", members=members) | ||
| + | </code> | ||
| + | <code python> | ||
| # apps.reporting.routes | # apps.reporting.routes | ||
| from flask import Blueprint | from flask import Blueprint | ||
| Línea 160: | Línea 166: | ||
| reporting.route("/member-report", methods=["GET","POST"])(report_on_members) | reporting.route("/member-report", methods=["GET","POST"])(report_on_members) | ||
| + | </code> | ||
| + | <code python> | ||
| # apps.application | # apps.application | ||
| from flask import Flask | from flask import Flask | ||
| Línea 168: | Línea 176: | ||
| db.init_app(app) | db.init_app(app) | ||
| app.register_blueprint(reporting) | app.register_blueprint(reporting) | ||
| + | </code> | ||
| + | |||
| + | Another example: | ||
| + | <code python> | ||
| + | app = Flask(__name__, static_path='') | ||
| + | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///digin.db' | ||
| + | db.init_app(app) | ||
| + | with app.app_context(): | ||
| + | db.create_all() | ||
| </code> | </code> | ||
| ===== HTML and JavaScript ===== | ===== HTML and JavaScript ===== | ||