This project is delivering backend service of page summarizer using various stacks that are pivoting around fastapi
, docker
, postgresql
, pytest
and nltk
. Dedicated to develop based on test driven as best practice in software development and also with Continuous Integration and Continuous Development.
For development :
Simply clone, docker-compose up -d --build
and redirect to http://localhost:8004/docs. To do unit test, execute docker-compose exec python -m pytest
.
For usage as service :
- Adding a new summary
$ http --json POST https://evening-brook-44287.herokuapp.com/summaries/ url=https://your_url.etc
example:
$ http --json POST http://localhost:8004/summaries/ url=http://testdriven.io
HTTP/1.1 201 Created
content-length: 34
content-type: application/json
date: Sun, 10 May 2020 15:59:54 GMT
server: uvicorn
{
"id": 5,
"url": "http://testdriven.io"
}
- Get the summary
$ http GET https://evening-brook-44287.herokuapp.com/summaries/{output_id}/
example
$ http GET http://localhost:8004/summaries/5/
HTTP/1.1 200 OK
content-length: 134
content-type: application/json
date: Sun, 10 May 2020 16:00:09 GMT
server: uvicorn
{
"created_at": "2020-05-10T15:59:55.098074",
"id": 5,
"summary": "",
"url": "http://testdriven.io"
}
feel free to try hit this service as api to your webapp!
- Develop an asynchronous RESTful API with Python and FastAPI
- Practice Test-Driven Development
- Test a FastAPI app with pytest
- Interact with a Postgres database asynchronously
- Containerize FastAPI and Postgres inside a Docker container
- Run unit and integration tests with code coverage inside a Docker container
- Check your code for any code quality issues via a linter
- Configure GitHub Actions for continuous integration and deployment
- Use GitHub Packages to store Docker Images
- Speed up a Docker-based CI build with Docker Cache
- Deploy FastAPI, Uvicorn, and Postgres to Heroku with Docker
- Parameterize test functions and mock functionality in tests with pytest
- Run tests in parallel with pytest-xdist
- Document a RESTful API with Swagger/OpenAPI
- Run a background process outside the request/response flow
├── .github
│ └── workflows
│ └── main.yml
├── .gitignore
├── README.md
├── docker-compose.yml
├── project
│ ├── .coverage
│ ├── .coveragerc
│ ├── .dockerignore
│ ├── Dockerfile
│ ├── Dockerfile.prod
│ ├── app
│ │ ├── __init__.py
│ │ ├── api
│ │ │ ├── __init__.py
│ │ │ ├── crud.py
│ │ │ ├── ping.py
│ │ │ └── summaries.py
│ │ ├── config.py
│ │ ├── db.py
│ │ ├── main.py
│ │ ├── models
│ │ │ ├── __init__.py
│ │ │ ├── pydantic.py
│ │ │ └── tortoise.py
│ │ └── summarizer.py
│ ├── db
│ │ ├── Dockerfile
│ │ └── create.sql
│ ├── entrypoint.sh
│ ├── htmlcov
│ ├── requirements-dev.txt
│ ├── requirements.txt
│ ├── setup.cfg
│ └── tests
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_ping.py
│ ├── test_summaries.py
│ └── test_summaries_unit.py
└── release.sh