GithubHelp home page GithubHelp logo

drewmoto / pymicroservtemplate Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 53 KB

pysthon micro service template

License: GNU General Public License v3.0

Python 73.10% Dockerfile 7.47% Makefile 19.43%

pymicroservtemplate's Introduction

Cookiecutter Python Microservice

Cookiecutter template for a Python microservice.

Features

Quick Start

Install the latest Cookiecutter if you haven't installed it yet (this requires Cookiecutter 1.4.0 or higher):

  $ pip install --upgrade virtualenv
  $ virtualenv env
  $ source env/bin/activate
  $ pip install -U cookiecutter

Generate a Python Microservice project:

  (env) $ cookiecutter https://github.com/python-microservices/microservices-template.git
    project_repo_url [https://github.com/python-microservices/microservices-scaffold]: 
    project_name [Python Microservices Boilerplate]: prueba descarga
    project_folder [prueba_descarga]: 
    project_short_description [Python Boilerplate contains all the boilerplate you need to create a Python package.]: 
    create_model_class [y]: 
    microservice_with_swagger_and_connexion [y]: 
    microservice_with_traces [y]: 
    microservice_with_metrics [y]: 
    application_root [/prueba_descarga]: 
    Select open_source_license:
    1 - MIT license
    2 - BSD license
    3 - ISC license
    4 - Apache Software License 2.0
    5 - GNU General Public License v3
    6 - Not open source
    Choose from 1, 2, 3, 4, 5, 6 [1]: 
  

Installation

Install with virtualenv

virtualenv --python=python[3.6|3.7|3.8] venv
source venv/bin/activate
pip install -r requirements.txt

Install with pipenv

pip install pipenv
pipenv install

Advantages over plain pip and requirements.txt

Pipenv generates two files: a Pipfileand a Pipfile.lock.

  • Pipfile: Is a high level declaration of the dependencies of your project. It can contain "dev" dependencies (usually test related stuff) and "standard" dependencies which are the ones you'll need for your project to function
  • Pipfile.lock: Is the "list" of all the dependencies your Pipfile has installed, along with their version and their hashes. This prevents two things: Conflicts between dependencies and installing a malicious module.

For a more in-depth explanation please refer to the official documentation.

Run your python script

python manage.py runserver

Check the result

Your default endpoints will be in this url:

http://127.0.0.1:5000/films/
http://127.0.0.1:5000/actors/

This URL is set in your config.yml:

pyms:
  config:
    DEBUG: false
    TESTING: false
    APP_NAME: Template
    APPLICATION_ROOT : "" # <!---

You can acceded to a swagger ui in the next url:

http://127.0.0.1:5000/ui/

This PATH is set in your config.yml:

pyms:
  services:
    swagger:
      path: "swagger"
      file: "swagger.yaml"
      url: "/ui/" # <!---

Read more info in the documentation page: https://microservices-scaffold.readthedocs.io/en/latest/

Docker

You can dockerize this microservice wit this steps:

  • Create and push the image
    docker build -t films -f Dockerfile .
  • Run the image:
    docker run -d -p 5000:5000 films

pymicroservtemplate's People

Contributors

drewmoto avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.