Skip to content

ncsyvn/microservices-flask-python-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Contributor] [Forks] [Stargazers] [Issues] [MIT License]


Logo

Microservices Flask Python Example

Start with some basic application

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

About The Project

This source show you a basic microservices system with python language and Flask framework. There are 2 mini services that connect directly with its apis:

  • Authentication service
    • signup
    • login
  • Video service
    • create new video
    • get list videos
Architecture

(back to top)

Built With

This section should list any major frameworks/libraries used for your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

  • Python
  • Flask

(back to top)

Getting Started

This is an example of how you may give instructions on setting up your project locally.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Installation

Below is an instruction for installing and setting up auth_service. Do the same with video_service.

  1. Clone the repo

    git clone https://github.com/ncsyvn/microservices-flask-python-example.git
  2. Install library

    * Create virtual environent (venv/conda/...)
    * Active venv in terminal
    * pip install -r auth_service/requirements.txt
  3. Migrate db

    After migrate database successfully, we will have "migrations" folder in auth_app. Besides, in mysql db, we will see 2 new tables: user, token

    * Change database uri in settings file:
      Example: SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@127.0.0.1:3306/auth_service'
    * Open new terminal -> Go to "auth_service/auth_app" folder
    * cmd: 
          1. flask db init
          2. flask db migrate -m "message you want"
          3. flask db upgrade  
  4. Run code

    After install step 2&3 with both auth_service and video_service.

    Run 2 apps in 2 different ports (example: 5012 & 5013).

(back to top)

Test service

This is the postman collection to testing your API

Create new video with valid token example
Create video success with valid token
Create new video with failed without token
Create video failed without

(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)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Cong Sy Nguyen - ncsyvn@gmail.com

Other projects: https://github.com/ncsyvn?tab=repositories

(back to top)