Meeber Python is skeleton python with flask.
- PostgreSQL
- Python 2.7
- ORM (Sqlalchemy)
- pip
- Gunicorn
Meeber Python support Python2.7 and Python3.7.
Config and run. for configuration you can edit in file "config.json"
$ cd meeberpy
$ pip install -r requirements.txt
$ python main.py migrate
$ python main.py seed
$ python main.py run
$ python main.py start_gunicorn
gunicorn can run with worker and multithreading, you can setup in config.json
and gunicorn can save logs file
Meeber python is simple architecture folder.
$ python main.py create:controller -n testing
after run this command you will found 'testing' folder in controllers.
and new line code in file controllers/__init__.py
from testing.router import testing
app.register_blueprint(testing)
example for testing controller:
File | Description |
---|---|
controllers/__init__.py |
this a public routing, u can register blueprint here |
controllers/testing/__init__.py |
u can import local router here |
controllers/testing/router.py |
this a local router , u can add more entities here |
controllers/testing/modules/__init__.py |
this a modules for use in your endpoint, u can add more function in here |
- open file controllers/yourcontroller/modules/
__init__.py
and add this to end of filedef get(): return "hello?"
- open file controllers/yourcontroller/router.py and add this to end of file
this will be creating new entities like "hostname:port/yourcontroller/new_entities" with GET method
@yourcontroller.route('/new_entities',methods=['GET']) def get_data(): return get()
- get() is import from modules/
__init__.py
-
cek your
__init__.py
file inmodules
make sure this importfrom manager.json_response import response
-
add this in function to return. ex:
def get(): json_data={"title":"this title","description":"this description"} return response(data=json_data,code=200,messages="success")
this will be return
{ "meta": { "message": "success", "code": 200, "server": "cc15b6a3-fe2a-3294-8fec-6c5aee285a48" }, "data": { "title":"this title", "description":"this description" } }
Name Type Description code INT this is code for header response and status message String message for response data String, Array, Object data for return