https://github.com/dkatz23238/auto-api
Automatically create backend-apis with one yaml file
https://github.com/dkatz23238/auto-api
Last synced: 3 months ago
JSON representation
Automatically create backend-apis with one yaml file
- Host: GitHub
- URL: https://github.com/dkatz23238/auto-api
- Owner: dkatz23238
- Created: 2019-04-28T02:11:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-23T20:34:19.000Z (about 6 years ago)
- Last Synced: 2025-01-19T08:28:14.732Z (5 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# auto-api
0. Populate auto-api.yml file
1. ```python -m pip install -r requirements.txt``` or ```python setup.py```
2. python makeapi.py >> app.py# auto-api.yml file
``` yaml
# one primary_key per table
# types: Boolean, Unicode, Integer, Date, DateTime, or Float
people:
first_name:
dtype: Unicode
primary_key: true
last_name:
dtype: Unicode
age:
dtype: Integerteams:
team_name:
dtype: Unicode
team_id:
dtype: Unicode
length: 36
primary_key: true```
This will generate the following python code:```python
import flask
import flask_sqlalchemy
import flask_restlessapp = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = flask_sqlalchemy.SQLAlchemy(app)class people(db.Model):
first_name = db.Column(db.Unicode(), primary_key=True)
last_name = db.Column(db.Unicode())
age = db.Column(db.Integer())class teams(db.Model):
team_name = db.Column(db.Unicode())
team_id = db.Column(db.Unicode(36), primary_key=True)db.create_all()
manager = flask_restless.APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(people, methods=['GET', 'POST', 'DELETE'])
manager.create_api(teams, methods=['GET', 'POST', 'DELETE'])
if __name__ == '__main__':# main()
app.run(port=5353)```