Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sartim/flask-headless-cms
Python (Flask) Headless CMS. This is a simple tool for generating a database structure & an API for content management.
https://github.com/sartim/flask-headless-cms
flask headless-cms python
Last synced: 23 days ago
JSON representation
Python (Flask) Headless CMS. This is a simple tool for generating a database structure & an API for content management.
- Host: GitHub
- URL: https://github.com/sartim/flask-headless-cms
- Owner: sartim
- License: mit
- Created: 2018-11-19T19:42:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-11-09T13:40:10.000Z (about 3 years ago)
- Last Synced: 2024-11-06T05:19:44.405Z (2 months ago)
- Topics: flask, headless-cms, python
- Language: Python
- Homepage:
- Size: 109 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask Headless CMS
[![Open Source Love](https://img.shields.io/badge/language-python-green.svg)](https://github.com/sartim/flask-headless-cms)
[![Open Source Love](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://github.com/sartim/flask-headless-cms/blob/master/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sartim/flask-headless-cms/issues)
[![Build Status](https://travis-ci.com/sartim/flask-headless-cms.svg?branch=master)](https://travis-ci.com/sartim/flask-headless-cms)## Overview
A tool for generating a database structure and an API for content management. Generated SQLAlchemy models and endpoints based on content types created via API.
### Features
- Support SQLAlchemy models
- Model generator
- Databases: PostgreSQL### Setup
_On Mac_$ brew install python
$ pip3 install virtualenv_On Linux_
$ pip3 install virtualenv
### Installation
$ pip3 install FlaskHeadlessCms
or$ git clone https://github.com/sartim/flask-headless-cms.git
$ cd flask-headless-cms
$ python install .After installation close & start a new terminal session.
### Start new project
$ flaskcli
#### Make Migrations
$ cd
$ python manage.py db init
$ python manage.py db migrate
$ python manage.py db upgrade
### APIURL: `/field/param`
METHOD: `POST`
BODY:
```
{
"content_name": "",
"fields": [{
"column_name": "id",
"data_type": "data_type",
"data_size": ,
"is_primary_key": boolean,
"is_foreign_key": boolean,
"is_null": boolean,
"default": null
},
............
],
"methods": ["GET, "POST"]
}
```_Example_
**With no relation**
```
{
"content_name": "user",
"fields": [
{
"column_name": "id",
"data_type": "INTEGER",
"data_size": null,
"is_primary_key": true,
"is_foreign_key": false,
"is_null": false,
"default": null
},
{
"column_name": "name",
"data_type": "VARCHAR",
"data_size": 255,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": null
},
{
"column_name": "password",
"data_type": "VARCHAR",
"data_size": 255,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"defualt": null
},
{
"column_name": "phone_number",
"data_type": "VARCHAR",
"data_size": 255,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": null
},
{
"column_name": "is_active",
"data_type": "BOOLEAN",
"data_size": null,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": false
},
{
"column_name": "confirmed_date",
"data_type": "TIMESTAMP",
"data_size": null,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": "CURRENT_TIMESTAMP",
"on_update_default": null
}
],
"methods": ["GET", "POST", "PUT", "DELETE"]
}
```**With relation**
```
{
"content_name": "user_role",
"fields": [
{
"column_name": "user_id",
"data_type": "INTEGER",
"is_primary_key": true,
"is_foreign_key": true,
"content_name_relation": "user"
},
{
"column_name": "role_id",
"data_type": "INTEGER",
"is_primary_key": true,
"is_foreign_key": true,
"content_name_relation": "role"
},
],
"methods": ["GET", "POST", "PUT", "DELETE"]
}
```_Overriding house keeping fields_
```
{
"content_name": "user",
"fields": [
.......
{
"column_name": "created_date",
"data_type": "TIMESTAMP",
"data_size": null,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": "CURRENT_TIMESTAMP",
"on_update_default": null
},
{
"column_name": "updated_date",
"data_type": "TIMESTAMP",
"data_size": null,
"is_primary_key": false,
"is_foreign_key": false,
"is_null": false,
"default": "CURRENT_TIMESTAMP",
"on_update_default": "CURRENT_TIMESTAMP"
}
.......
]
}
```
| Allowed Fields | Type | Example |
| ---------------- |:-------------: | -----------------------------------------------:|
| column_name | String | first_name, name, user_id |
| data_type | String | VARCHAR, TIMESTAMP, INTEGER, BOOLEAN, DECIMAL |
| data_size | Integer | 255 |
| is_primary_key | Boolean | true, false |
| is_foreign_key | Boolean | true, false |
| is_null | Boolean | true, false |
| default | String | false, CURRENT_TIMESTAMP |
| on_update_default | String | CURRENT_TIMESTAMP |
| content_name_relation | String | |