|Keywords:||a2billing, api, flask|
Each RestFul APIs exposed supports the following:
/api/<model name>/ – GET and POST requests
/api/<model name>/<primary key>/ – GET, PUT and DELETE requests
Also, you can filter results by columns on the model. For example:
An install shell script is provided at https://github.com/areski/a2billing-flask-api/tree/master/install
The install script is intended to run on Debian 8.
wget https://raw.githubusercontent.com/areski/a2billing-flask-api/master/install/install-a2b-flask-api.sh bash install-a2b-flask-api.sh
This Application is build using Flask and Peewee:
See the file requirements.txt for the full list of requirements.
An Admin Panel is provided which can be accessed at http://<ip_address>:8008/admin/
You will need an admin username and password to login, see the section below on how to create an admin user.
Use ab, the Apache HTTP server benchmarking tool
ab -c 100 -n 1000 -p test/post.txt -T application/x-www-form-urlencoded http://localhost:8008/api/cardgroup/
Install & Deployment¶
There are many ways to deploy a Flask Application, we will describe the Apache Method here as this is the one more suitable for A2Billing users.
Edit a2billing_flaskapi.py and change the secret key and keep this really secret:
app.secret_key = 'ssshhhh-and-changeme-when-deploying'
Create an Admin User¶
We now have a functioning admin site, you can login with user / password: admin / admin
Change immediately the default password by a strong password!!!
You might want to create an other admin user from shell, to do so open up an interactive python shell in the directory alongside the app and run the following:
$ cd /usr/share/a2billing-flask-api/ $ workon a2billing-flask-api $ python
Then in Python interpreter, type the following:
from a2billing_flask_api import auth auth.User.create_table(fail_silently=True) # make sure table created. admin = auth.User(username='admin', email='', admin=True, active=True) admin.set_password('admin') admin.save()
Check out the documentation on ‘Read the Docs’: http://a2billing-flask-api.readthedocs.org/en/latest/index.html
If you’ve found a bug, add a feature or improve the project and think it is useful then please consider contributing. Patches, pull requests or just suggestions are always welcome!
Source code: https://github.com/areski/a2billing-flask-api/
If you don’t like Github and Git you’re welcome to send regular patches.
A2Billing-Flask-API is licensed under MPLv2.