Skip to content

Commit

Permalink
更新readme
Browse files Browse the repository at this point in the history
  • Loading branch information
misakar committed Oct 30, 2015
1 parent efb4a42 commit 9c8034b
Show file tree
Hide file tree
Showing 44 changed files with 69 additions and 144 deletions.
61 changes: 43 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,29 @@ mana

## 使用mana:
### 1. mana init --> 构建你的项目
#### 1. 构建一般项目(无蓝图、无数据库、无配置文件)

~> mana init my_project
$ mana init my_project

你已经创建了你的目录结构(如图)<br/>
创建的目录结构(如图)<br/>

|-app/ ---- __init__.py
|-test/
my_project - | views.py
|-requirement.txt forms.py
|-README.md templates
| static

文件中预填代码<br/>
[app/__init__.py预填代码](https://github.com/neo1218/mana/blob/master/examples/GoodIdea/app/__init__.py) : 创建了flask app, 导入了基本配置 <br/>
现在你只需开开兴兴的写视图了

#### 2. 构建中型项目(无蓝图、有数据库、有配置文件)

默认集成的是flask-sqlalchemy数据库扩展🍺
$ mana init my_project --sql=true

创建的目录结构(如图)<br/>

|-app/ ---- __init__.py
|-test/ models.py
Expand All @@ -26,9 +45,25 @@ mana
|-README.md templates
| static

并且在相关文件中预填了代码<br/>
[config.py预填代码](https://github.com/neo1218/mana/blob/master/examples/GoodIdea/config.py) : 三个配置类, 对应生产、测试、开发环境配置 <br/>
文件中预填代码<br/>
[app/__init__.py预填代码](https://github.com/neo1218/mana/blob/master/examples/GoodIdea/app/__init__.py) : 创建了flask app, 导入了基本配置
[config.py预填代码](): 测试、生产、开发环境下配置
[models.py预填代码](): 导入 db 对象

#### 3. 构建大型项目(有蓝图、有数据库、有配置文件)

将mana init与mana blue搭配使用

命令如下

# 构建项目
$ mana init my_project --sql=true

# 自动创建、注册蓝图
$ mana blue my_project <蓝图名>

具体见 ~mana blue~ 的用法


### 2. mana install (--venv) --> 安装flask扩展
在 requirement.txt 中写入你希望安装的扩展的名称 <br/>
Expand All @@ -50,17 +85,7 @@ ex:
这样你的扩展就会被安装到全局中<br/>
不过强烈建议使用使用虚拟环境进行开发,参见[virtualenv](http://docs.jinkan.org/docs/flask/installation.html#virtualenv) <br/>


### 3. mana sql --> 集成 flask-sqlalchemy 处理关系型数据库
对于sql数据库的处理, flask-sqlalchemy 是我最常用的扩展,使用mana可以快速集成flask-sqlalchemy并初始化扩展

进入与项目根目录同级的目录 🍺
$ mana sql project_name

接下来,你只需要专心于models.py的数据库类设计与编码了<br/>


### 4. mana manage --> 使用 manage.py 管理你的项目
### 3. mana manage --> 使用 manage.py 管理你的项目
还可以使用mana创建manage.py集成flask-script和flask-migrate管理我们的项目

进入与项目根目录同级的目录 🍺
Expand Down Expand Up @@ -99,7 +124,7 @@ ex:
>> User
<class 'app.models.User'>

### 5. mana blue (--prefix)--> 自动注册蓝图
### 4. mana blue (--prefix)--> 自动注册蓝图

进入与项目根目录同级的目录 🍺
$ mana blue project_name bluep
Expand All @@ -111,14 +136,14 @@ ex:

这样就可以通过 /bluep/... 去访问蓝图对应的视图

### 6. mana deploy --> deploy flask application on wsgi server
### 5. mana deploy --> deploy flask application on wsgi server

进入与项目根目录同级的目录 🍺
$ mana deploy project_name --host=121.43.230.104 --port=2333

这样就可以创建wsgi.py去部署你的flask应用

### 7. mana what? --> use your imagination ..
### 6. mana what? --> use your imagination ..

未完 .... 待续 ....

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

from . import views, models, forms
app.register_blueprint('share', url_prefix='/share')
app.register_blueprint('book')
Binary file not shown.
13 changes: 13 additions & 0 deletions example/Test2/app/book/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# coding: utf-8
"""
~~~~~~~
"""

from flask import Blueprint


book = Blueprint("book", __name__, static_folder='static', template_folder='templates')


from . import views, forms
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added example/Test2/app/forms.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
"""
from . import db


class User():
pass
Binary file added example/Test2/app/models.pyc
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added example/Test2/app/views.pyc
Binary file not shown.
File renamed without changes.
Binary file added example/Test2/config.pyc
Binary file not shown.
File renamed without changes.
2 changes: 2 additions & 0 deletions example/Test2/requirement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
flask-sqlalchemy
17 changes: 0 additions & 17 deletions examples/init_cfg_project/app/__init__.py

This file was deleted.

47 changes: 0 additions & 47 deletions examples/init_cfg_project/config.py

This file was deleted.

Empty file.
Empty file removed examples/init_sql_config/README.md
Empty file.
Binary file removed examples/init_sql_config/app/forms.pyc
Binary file not shown.
Binary file removed examples/init_sql_config/app/models.pyc
Binary file not shown.
Binary file removed examples/init_sql_config/app/views.pyc
Binary file not shown.
Binary file removed examples/init_sql_config/config.pyc
Binary file not shown.
Empty file.
Empty file removed examples/project/README.md
Empty file.
15 changes: 0 additions & 15 deletions examples/project/app/__init__.py

This file was deleted.

Binary file removed examples/project/app/__init__.pyc
Binary file not shown.
Empty file removed examples/project/app/forms.py
Empty file.
Binary file removed examples/project/app/forms.pyc
Binary file not shown.
Empty file removed examples/project/app/views.py
Empty file.
Binary file removed examples/project/app/views.pyc
Binary file not shown.
47 changes: 0 additions & 47 deletions examples/project/manage.py

This file was deleted.

Empty file removed examples/project/requirement.txt
Empty file.
7 changes: 7 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from flask import Flask


app = Flask(__name__)



0 comments on commit 9c8034b

Please sign in to comment.