# base_flask_template **Repository Path**: contexter/base_flask_template ## Basic Information - **Project Name**: base_flask_template - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2019-06-18 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 项目基于flask+python开发, 采用python3开发, 本次使用版本3.6.7 #### 开发环境搭建 ```python git clone https://git.oschina.net/xxxxxx/note_book_server.git cd note_book_server cp config.py.example config.py virtualenv venv source venv/bin/activate ubuntu: sudo apt-get install libmysqlclient-dev libssl-dev libcurl4-openssl-dev python-dev centos7: yum install libcurl-devel pip install pycurl --global-option="--with-nss" pip install -r requirements/requirements.txt ``` #### 创建数据库 ```python sudo -u postgres createuser mooc --no-createdb --no-superuser --no-createrole --pwprompt sudo -u postgres createdb note_book_server --owner=mooc ``` #### 初始化数据库 ```python python manage.py db init python manage.py db migrate python manage.py db upgrade ``` 4、回滚事物   1)运行 python manage.py db history     查看历史版本,得到history-id   2)运行 python manage.py db downgrade history-id     回退到指定历史版本 ``` #### 初始化数据库数据 ```python python manage.py deploy ``` #### 启动: ```python export FLASK_ENV=development export FLASK_ENV=production python manage.py runserver ``` #### 代码目录结构 html 总分三层: view: 跟浏览器交互 service: 处理业务的 models: 跟数据库交互的 页面渲染采用继承的模板, 模板样列 templates: example.html 接口部分: routes: 路由层次 apis: 跟浏览器交互 service: 处理业务的 models: 跟数据库交互的 api: [API](doc/api/api.md) ``` npm install -g i5ting_toc cd doc/api i5ting_toc -f api.md ``` #### 队列调用说明 启动队列: ```python cd note_book_server celery worker -A celery_worker.celery --loglevel=info ``` #### websocket ``` async_mode = "gevent" for development: python web_socketio.py for production: gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 web_socketio:app ``` #### 生产环境请参考 [deploy](doc/deploy.md).