Skip to content

Glico21/BananaAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn

coverage-shield


Logo

Banana API

Simple Flask API
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

This is BananaAPI. A project to demonstrate a possible configuration of a simple API project in Flask. Allows you to work with bananas by CRUD. Uses SQLAlchemy ORM and Marshmallow as a serializer to interact with the database. The project is based on the tutorial by Leonardo Giordani. All API development is done via TDD.

(back to top)

Built With

  • Python
  • Flask
  • PostgreSQL
  • Docker
  • Nginx
  • Gunicorn
  • Pytest

(back to top)

Getting Started

  • Install Docker on your machine.

Installation

  1. Clone the repo
    git clone https://github.com//Glico21/BananaAPI.git
  2. Use virtual environments and install all necessary requirements
    pip install -r requirements/development.txt
  3. Also you need to build the container
    ./manage.py compose build web

(back to top)

Usage

The API can work in three modes. In development, production and testing modes.

Development

Development mode runs the application as a separate container, independent of the database, which is also in a separate container. It uses separate development server specific environment variables.

You can run development mode by this command

./manage.py compose up

This command will start the application on localhost 0.0.0.0:5000.

After that, you need to migrate to initialize all the necessary tables for the database.

./manage.py flask db migrate -m "Some message"

And upgrade

./manage.py flask db upgrade

You can check out the available endpoints and see how it all works.

Production

Production mode also runs the application in a separate container, but it can be scalable by nginx and gunicorn.

You can run production server by this command

APPLICATION_CONFIG="production" ./manage.py compose up

If you want scale application for N containers you should use this command

APPLICATION_CONFIG="production" ./manage.py compose up --scale web=N

Testing

You can run separate tests for the application. To do this, run the following command.

./manage.py test

A separate database is used for the tests, which is cleared automatically after each test is performed.

Endpoints list

URL/Method GET POST PATCH DELETE
/ Return Hello, World!
/users Return count of users in database
/bananas Return all banana objects Create a banana object
/palms Return all palms objects Create a palm object
/bananas/<id> Return a specific banana object Update a banana object Delete a banana object
/palms/<id> Return a specific palm object Update a palm object Delete a palm object

(back to top)

Roadmap

In the future it is planned to develop this project a little bit.

  • Add a palm tree model, which will be linked to the banana model.
  • Add more fields for the banana
  • Expand user model
  • Add simple authorization and access rights

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact me

Boyko Dmitriy - 21glicodin@gmail.com

Project Link: https://github.com/Glico21/BananaAPI

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published