开发笔记与文档:《用 Flask 来写个轻博客》
- Step 1: clone the source code from GitHub
git clone https://github.com/JmilkFan/JmilkFan-s-Blog.git
cd JmilkFan-s-Blog
- Step 2: building and using virtual environment via tools of
virtualenv
virtualenv blog_env
source blog_env/bin/activate
- Step 3: Install the requirements package
pip install -r requirements.txt -e .
- Srep 1: Create the DB for app of jmilkfansblog, e.g.
mysql -uroot -pfanguiju -e "CREATE DATABASE myblog default charset utf8 COLLATE utf8_general_ci;"
mysql -uroot -pfanguiju -e "GRANT ALL ON egis.* TO 'user'@'127.0.0.1' IDENTIFIED BY 'fanguiju';"
mysql -uroot -pfanguiju -e "GRANT ALL ON egis.* TO 'user'@'localhost' IDENTIFIED BY 'fanguiju';"
mysql -uroot -pfanguiju -e "GRANT ALL ON egis.* TO 'user'@'%' IDENTIFIED BY 'fanguiju';"
- Step 2: Setup the Configuration.
Edit the config optionconnectionfor etc fileetc/jmilkfansblog.confe.g.
connection = 'mysql+pymysql://root:fanguiju@127.0.0.1:3306/myblog?charset=utf8'
Edit the config option host/server_port/api_port. e.g.
host = '127.0.0.1'
server_port = 8089
api_port = 8080
- Step 3: Init the database
jmilkfansblog-manager db upgrade -d jmilkfansblog/db/sqlalchemy/alembic
- Step 4: Start the service
jmilkfansblog-manager server
- Step 5: Start the API service
jmilkfansblog-api
- Step 6: Register the account(Have to access the google reCAPTCHA).
http://127.0.0.1:8088/register
- ERROR:
Command "python setup.py egg_info" failed with error code 1if you meet this error when you installing the dependency packet from requirements file. Plase check whether installed the MySQL, because the package PyMySQL will be depend on it.
============== 2016-11-13 =============
- First commit
- Completed development environment configuration
- Created the base application
- Installed the Flask extend: Flask-Script CLI
- Installed the Flask extend: Flask-SQLAlchemy
- Connect the MySQL with SQLAlchemy
============== 2016-11-16 =============
- Created the database myblog
- Implements models class User
============== 2016-11-19 =============
- Implements models class Post
============== 2016-11-20 =============
- Implements models class Comment
- Implements models class Tag
- Installed the Flask extend: Flask-Migrate
============== 2016-11-23 =============
- Added the file views.py
- Created the view function for tables
- Installed the Bootstrap
- Implements the HTML base template of Jinja
- Implements the macro: render pagination
- Fix the bug from base.html
============== 2016-11-24 =============
- Implements the template for view function:
home() - Installed the Flask-WTF
- Implements the Form class:
CommentForm
============== 2016-11-24 =============
- Fix the bug for pagination linked
- Implements template:
post.html - Add the Form class CommentForm() into view function:
post()
============== 2016-11-26 =============
- Add the template:
page_not_fount.html - Implements the Blueprint:
blog - Reconstruction project code
============== 2016-11-27 =============
- Using the Factory Method to create app instance
- Installed the Flask-Bcrypt
- Using the Flask-Bcrypt to encipher the password
- Using reCAPTCHA
- Implements Login and Register Forms
============== 2016-11-28 =============
- Fix the bug for reCAPTCHA
- Implements view function login/logout/register
- Implements template:
login.html
============== 2016-11-29 =============
- Implements the template:
register.html
============== 2016-11-30 =============
- Implements the View function: new_post/edit_post
- Implements the template: new.html/edit.html
- Fix the bug for edit and new the post
============== 2016-12-02 =============
- Fix the bug for controller:
blog.py
============== 2016-12-03 =============
- Fix the bug for login/register/net_post/edit_post
============== 2016-12-04 =============
- Installed the Flask-OpenID
- Implements use the OpenID to login the blog
- Installed the Flask-Oauth
- Implements use the Facebook and Twitter to login the blog
- Installed the Flask-Login
- Installed the Flask-Principal
- Using the session to confirm the uses login status
- Add the table:
users_rolesandroles - Using the Flask-Principal to implements the role permission
- Using the Flask-Login to implements the ensure the user login status
============== 2016-12-05 =============
- Fix some bug for Flask-Principal
============== 2016-12-06 =============
2. Add the Remember Me optional box
============== 2016-12-08 =============
- Add the Script plug-in with duoshuo-comment
- Add the Script plug-in with duoshuo-share
============== 2016-12-09 =============
- Fix some bug for Flask-Principal
============== 2016-12-10 =============
- Installed the Flask-Restful
- Implements restful api
GETfor /api/posts - Implements restful api
POSTfor /api/posts - Implements restful api
PUTfor /api/posts/post_id - Implements restful api
DELETEfor /api/posts/post_id - Implements restful api
POSTfor /api/auth
============== 2016-12-11 =============
- Added the database migrate version:
Init database - Added the table
browse_volumes - Added the database migrate version:
Add table of browse_volumes - Fix some bug
- Installed Celery and Flask-Celery-Helper
============== 2016-12-12 =============
- Implements the celery_runner(Celery worker)
============== 2016-12-13 =============
- Installed flower
- Setup the timed task
- Add table
reminders - Implements Remind when registered the user
- Implements weekly digest
============== 2016-12-14 =============
- Implements email content of weekly-digest
digest.html - Installed Flask-Debug-Toolbar
- Installed Flask-Cache
- Installed Flask-Redis
- Implements make cache for
post.html/home.htmland functionverify_auth_token - Using Redis as BackEndStieCache
- Installed Flask-Assets
- Installed Flask-Admin
- Implements the Post-Admin page via Flask-Admin
- Implements access File System via Flask-Admin
- Installed Flask-Mail
============== 2016-12-15 =============
- Fix some bug
============== 2016-12-16 =============
- Fix some bug
============== 2016-12-17 =============
- Fix some bug for Flask-Admin
- Replace the property of Post Model:
userstouser
============== 2016-12-18 =============
- Create a new manager command
assset - Pack up the static file
- Fix the bug for UnicodeEncodeError
============== 2016-12-19 =============
- Implements Flask-Youku extension
- Implements Flask-GZip extension
============== 2016-12-20 =============
- Packup the extensions Flask-Youku and Flask-GZip
============== 2016-12-21 =============
- Installed selenium
- Installed coverage
- Implements Unit test
TestURLs - Fix some bug
============== 2016-12-24 =============
- Fix some bug for flask_youku
- Installed oslo_config
- Using oslo_config to setup the config
============== tag 0.0.1 Done to Python-Flask =============
============== 2016-12-26 =============
- Fix the bug for oslo_config
- Implements setup.cfg and setup.py
- Tag 0.0.1 Done to Python-Flask
- Source archive v0.0.1
============== 2016-12-27 =============
- Installed Pecan
- Implements Restful api
v1/usersvia Pecan - Create the db directory
- Create the api directory for Pecan RESTful API
============== 2016-12-28 =============
- Implements RESTful API
v1/postsvia Pecan
============== 2016-12-30 =============
- Installed oslo_db
- Using oslo_db.sqlalchemy.session.EngineFacahe to create the session
- Using oslo_db.concurrency to wrapper the operation of database
============== 2017-01-02 =============
- Fix the bug for Flask-Admin
- Return post_id when response the flask_restful api
/postsGET
============== 2017-01-04 =============
- Implements the GET
v1/postsvia pecan RESTful
============== 2017-01-05 =============
- Installed oslo_i18n
- Try to use the oslo_log and oslo_config
============== 2017-01-08 =============
- Fix some bug
- Implements console-script via setup.cfg
============== 2017-01-09 =============
- Fix the bug for db.api.CONF
============== 2017-03-31 =============
- Test the oslo_config
============== 2017-04-03 =============
- Fix the oslo_log and jinja syntax bug