Code Monkey home page Code Monkey logo

docker-flask-api's Introduction

Docker Flask API template ๐Ÿณ

Top language Code size Last commit License Twitter follow

This repository aims to be an easy to extend template for building a Python API using Flask and running it with only Python or using Docker.

Prerequisities

Before you begin, ensure you have met the following requirements:

For only-Docker usage:

  • You have a Windows/Linux/Mac machine with the latest version of Docker installed.

For only-Python usage:

For general purposes, why not installing prerequisites for both cases?

Install/Run with only Python

If you want to install the dependencies and work locally using only Python, you can simply follow this steps. If you want to directly work using Docker, jump to the "Install/Run with Docker" section.

Clone the project repository:

git clone https://github.com/RodolfoFerro/docker-flask-api.git
cd docker-flask-api

To create and activate the virtual environment, follow these steps:

Using conda:

$ conda create -n docker-flask python=3.7

# Activate the virtual environment:
$ conda activate docker-flask

# To deactivate:
(docker-flask)$ conda deactivate

Using virtualenv:

# In this case I'm supposing that your latest python3 version is +3.6
$ virtualenv docker-flask --python=python3

# Activate the virtual environment:
$ source docker-flask/bin/activate

# To deactivate:
(docker-flask)$ deactivate

To install the requirements using pip, once the virtual environment is active:

(docker-flask)$ pip install -r requirements.txt

Finally, if you want to run the app locally, simply run:

$ python app.py

Now you should be able to test the API at http://0.0.0.0:5000/.

Install/Run with Docker

If you want to install the dependencies and work using Docker, you can simply follow this steps. If you want to simply work locally using only Python, jump back to the "Install/Run with only Python" section.

Clone the project repository:

git clone https://github.com/RodolfoFerro/docker-flask-api.git
cd docker-flask-api

To build the Docker image, simply run:

$ docker build -t docker-flask-api .

To run the Docker image, run the following:

$ docker run -it -p 5000:5000 -v $(pwd):/app  docker-flask-api

Now you should be able to test the API at http://localhost:5000/.

To stop the Docker container:

$ docker ps
$ docker stop <container-id>

Contributing

To contribute to <project_name>, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <feature_branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create a Pull Request.

Additionally you can see the GitHub documentation on creating a Pull Request.

Contact

If you want to contact me you can reach me at [email protected]. There, or through any other of my social profiles your can find at: https://rodolfoferro.glitch.me/

License

This project uses an MIT License.

docker-flask-api's People

Contributors

rodolfoferro avatar

Watchers

James Cloos avatar  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.