A flask RESTful API service that uses SQLAlchemy to store data into a PostgreSQL database. The text summarization is done using Natural Language Toolkit.
- Python = 3.7
- Postgres >= 10.0
- everything in Conda environment.yml file
Install Miniconda, then:
conda env update
conda activate flask_rest_env
- Create postgres database called
flask_rest_dev
for development orflask_rest_live
for production. - With an activated conda environment run:
export CONFIG_TYPE=dev
FLASK_APP=run.py flask db upgrade
Use "dev" for development server and "live" for production server.
FLASK_APP=run.py flask db migrate -m "Description of migration"
Replace the "Description of migration" with an appropriate description.
To view the history and current version
FLASK_APP=run.py flask db history
FLASK_APP=run.py flask db current
export FLASK_APP=run.py
flask run
Open api/document.py the doc strings will be very helpful.
curl http://localhost:5000/documents -X POST -H "Content-Type: application/json" -d '{"text":<contents of the document>}
curl http://localhost:5000/documents/<document_id>
curl http://localhost:5000/summary/<document_id>
curl http://localhost:5000/documents/<document_id> -X DELETE
Use Python Black formatting:
black --check --line-length 120 .
- With an activated conda environment run:
export CONFIG_TYPE=dev
python -m pytest unit_tests/ -vs