Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

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)
Comment

sqlite3 with flask web application CRUD pdf

$ pip install flask-migrate
Comment

sqlite3 with flask web application CRUD pdf

$ flask db init
Comment

sqlite3 with flask web application CRUD pdf

$ flask db migrate
Comment

sqlite3 with flask web application CRUD pdf

pip install Flask-WTF
Comment

sqlite3 with flask web application CRUD pdf

pip install flask-bootstrap
Comment

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>
Comment

sqlite3 with flask web application CRUD pdf

$ python tests.py

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Comment

sqlite3 with flask web application CRUD pdf

$ pip install flask-login
Comment

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()
Comment

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>
Comment

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')
Comment

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>
Comment

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)
Comment

PREVIOUS NEXT
Code Example
Python :: how to download excel file with password from online python 
Python :: getting range lowest and highest values from np array 
Python :: count number of repeats in list python 
Python :: Ornhgvshy vf orggre guna htyl 
Python :: sns.distplot fit 
Python :: input function in django 
Python :: how to use Py-agender for projects 
Python :: get_absolute_url method on the model 
Python :: how to make a dashboard with data representation using python free dash 
Python :: dargon 
Python :: gtk entry focus python 
Python :: I want only the span of finditer in re python 
Python :: tess real name from suits 
Python :: can i save additional information with png file 
Python :: Concatenação de Strings 
Python :: *args **kwargs together in python 
Python :: Python colorbar for circular heatmap 
Python :: cumulative some by date for each user 
Python :: pandas terms for list of substring present in another list python 
Python :: multipart encoder 
Python :: variable plus one python 
Python :: daraframe get top n max value 
Python :: how to bacome michael reeves in python 
Python :: difference between methods and attributes 
Python :: mutiplication of two number in python 
Python :: Python: Sending a variable to another script 
Python :: pick the element from list whihc matched with sub string 
Python :: python print x y coordinates 
Python :: networkx draw edge description 
Python :: Python - Comment préparer la capitalisation 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =