DekGenius.com
PYTHON
sqlite3 with flask web application CRUD pdf
# run.py
import os
from app import create_app
config_name = os.getenv('FLASK_CONFIG')
app = create_app(config_name)
if __name__ == '__main__':
app.run()
sqlite3 with flask web application CRUD pdf
$ export FLASK_CONFIG=development
$ export FLASK_APP=run.py
$ flask run
* Serving Flask app "run"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
sqlite3 with flask web application CRUD pdf
$ pip install flask-migrate
sqlite3 with flask web application CRUD pdf
sqlite3 with flask web application CRUD pdf
sqlite3 with flask web application CRUD pdf
sqlite3 with flask web application CRUD pdf
pip install flask-bootstrap
sqlite3 with flask web application CRUD pdf
<!-- app/templates/base.html -->
<!-- Modify nav bar menu -->
<li><a href="{{ url_for('admin.list_roles') }}">Roles</a></li>
sqlite3 with flask web application CRUD pdf
$ python tests.py
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
sqlite3 with flask web application CRUD pdf
$ pip install flask-login
sqlite3 with flask web application CRUD pdf
$ flask shell
>>> from app.models import Employee
>>> from app import db
>>> admin = Employee(email="admin@admin.com",username="admin",password="admin2016",is_admin=True)
>>> db.session.add(admin)
>>> db.session.commit()
sqlite3 with flask web application CRUD pdf
<!-- app/templates/base.html -->
<!-- Modify nav bar menu -->
<li><a href="{{ url_for('admin.list_departments') }}">Departments</a></li>
sqlite3 with flask web application CRUD pdf
# app/admin/forms.py
# existing code remains
class RoleForm(FlaskForm):
"""
Form for admin to add or edit a role
"""
name = StringField('Name', validators=[DataRequired()])
description = StringField('Description', validators=[DataRequired()])
submit = SubmitField('Submit')
sqlite3 with flask web application CRUD pdf
<!-- app/templates/base.html -->
<!-- Modify nav bar menu -->
<li><a href="{{ url_for('admin.list_employees') }}">Employees</a></li>
sqlite3 with flask web application CRUD pdf
$ mysql -u root
mysql> CREATE DATABASE dreamteam_test;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON dreamteam_test . * TO 'dt_admin'@'localhost';
Query OK, 0 rows affected (0.00 sec)
© 2022 Copyright:
DekGenius.com