Giter Club home page Giter Club logo

flask-boilerplate's Introduction

Flask Boilerplate

The MIT License

Flask Boilerplate to quickly get started with production grade flask application with some additional packages and configuration prebuilt.

You can find an in-depth article on this implementation here.

Contributing

We encourage you to contribute to Flask Boilerplate! Please check out the Contributing guidelines about how to proceed.

Getting Started

Prerequisites

  • Python 3.11.3 or higher
  • Up and running Redis client

Project setup

# clone the repo
$ git clone https://github.com/idris-rampurawala/flask-boilerplate.git
# move to the project folder
$ cd flask-boilerplate

If you want to install redis via docker

$ docker run -d --name="flask-boilerplate-redis" -p 6379:6379 redis

Creating virtual environment

  • Install pipenv a global python project pip install pipenv
  • Create a virtual environment for this project
# creating pipenv environment for python 3
$ pipenv --three
# activating the pipenv environment
$ pipenv shell
# install all dependencies (include -d for installing dev dependencies)
$ pipenv install -d

# if you have multiple python 3 versions installed then
$ pipenv install -d --python 3.11

Configuration

  • There are 3 configurations development, staging and production in config.py. Default is development
  • Create a .env file from .env.example and set appropriate environment variables before running the project

Running app

  • Run flask app python run.py
  • Logs would be generated under log folder

Running celery workers

  • Run redis locally before running celery worker
  • Celery worker can be started with following command
# run following command in a separate terminal
$ celery -A celery_worker.celery worker --loglevel='INFO'  
# (append `--pool=solo` for windows)

Preconfigured Packages

Includes preconfigured packages to kick start flask app by just setting appropriate configuration.

Package Usage
celery Running background tasks
redis A Python Redis client for caching
flask-cors Configuring CORS
python-dotenv Reads the key-value pair from .env file and adds them to environment variable.
marshmallow A package for creating Schema, serialization, deserialization
webargs A Python library for parsing and validating HTTP request objects

autopep8 & flake8 as dev packages for linting and formatting

Test

Test if this app has been installed correctly and it is working via following curl commands (or use in Postman)

  • Check if the app is running via status API
$ curl --location --request GET 'http://localhost:5000/status'
  • Check if core app API and celery task is working via
$ curl --location --request GET 'http://localhost:5000/api/v1/core/test'
  • Check if authorization is working via (change API Key as per you .env)
$ curl --location --request GET 'http://localhost:5000/api/v1/core/restricted' --header 'x-api-key: 436236939443955C11494D448451F'

License

This program is free software under MIT license. Please see the LICENSE file in our repository for the full text.

flask-boilerplate's People

Contributors

dependabot[bot] avatar idris-rampurawala avatar schiederme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flask-boilerplate's Issues

Log file cannot be created

Describe the bug
Running the app while throw the following value error.

ValueError: Unable to configure handler 'log_info_file'

To Reproduce
Steps to reproduce the behavior:

  1. Clone repository
  2. Configure repository copying .env.example to .env
  3. python run.py
  4. See error

Upgrade to Python 3.9

Is your feature request related to a problem? Please describe.
This will update Python and its dependencies to the latest versions of Python 3.9.

Upgrade to Python 3.11

Is your feature request related to a problem? Please describe.
This will update Python and its dependencies to the latest versions of Python 3.11

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.