Coder Social home page Coder Social logo

flask-blueprint's Introduction

flask-blueprint

A dummy Flask app used to showcase how a few different concepts and building blocks come together. Features:

Current Status

The app is currently under refactoring. The next step is to move the creation of the Celery instance to a make_celery()factory function inside api.__init__.py, and the Celery config to api.config.py.

The dev experience is not very user-friendly right now. We will move to docker-compose so that we don't have to manually start and manage all the different services (Flask, redis, flower, db...)

We may also move from pip to poetry for dependency management.

Another thing that's currently missing is tests (with e.g. Pytest), linters, formatters, and other code quality checkers, as well as a CI pipeline that uses these.

Running the app

Clone the app and cd into the root directory.

Create a virtual environment through your preferred method (pyenv-virtualenv, venv...) and activate it.

Install the dependencies:

pip install -r requirements.txt
  • Make sure you have a running Redis instance, either locally, or in a Docker container.

Locally:

$ redis-server
$ redis-cli ping  # Test that it's up and running
PONG

With Docker:

$ docker run -p 6379:6379 --name my-redis -d redis
$ docker exec -it my-redis redis-cli ping
PONG

In another terminal window/tab, start the Celery worker:

celery -A app.celery worker --loglevel=info

In a third terminal window/tab, start Celery flower:

celery -A app.celery flower --port=5555

You can now navigate to http://localhost:5555 to view the flower dashboard.

In your first terminal window/tab, start a flask shell:

FLASK_APP=app.py flask shell

Now you can send a task to celery:

>>> from app import divide
>>> task = divide.delay(10, 2)

It should appear on the flower dashboard (you may have to refresh the page), and in the celery worker logs.

You can also set up and explore the database (not needed for celery-redis):

$ FLASK_APP=app.py flask db upgrade

This will apply the initial migration and create the Users table. You can now play with it in the flask shell:

>>> from api.users.models import User
>>> user = User(username='geekLeek007', email='[email protected]')
>>> db.session.add(user)
>>> db.session.commit()
>>> User.query.first().username
'geekLeek007'

flask-blueprint's People

Contributors

blancadesal avatar nbarnabee 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.