Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinqqnj/flask-template-rq
a simple Flask app template for task queue.
https://github.com/kevinqqnj/flask-template-rq
Last synced: 3 months ago
JSON representation
a simple Flask app template for task queue.
- Host: GitHub
- URL: https://github.com/kevinqqnj/flask-template-rq
- Owner: kevinqqnj
- License: mit
- Created: 2018-01-10T10:51:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-13T14:04:34.000Z (almost 7 years ago)
- Last Synced: 2024-05-19T23:35:51.542Z (6 months ago)
- Language: Python
- Homepage: https://flaskrq.herokuapp.com/
- Size: 196 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask app template - RQ
> a simple Flask app template for Redis task queue.
> working with python3.
> Thanks to: Benjamin Bertrand https://beenje.github.io/blog/posts/running-background-tasks-with-flask-and-rq/
![snapshot](rq_snapshot.png "snapshot")
Live Demo: https://flaskrq.herokuapp.com/
It's based on a simple Flask template, check here: https://github.com/kevinqqnj/flask-template-simple
## Features:
- Simple but full structured Flask template to support RQ (Redis Queue)
- integrated with RQ, redis
- use Vue.js as frontend (you can replace as whatever frontend you like)
- frontend shows dashboard of queued tasks## Prerequisite
You should have Redis installed.
> Ubuntu:
```
sudo wget http://download.redis.io/redis-stable.tar.gz
sudo tar xzf redis-stable.tar.gz
cd redis-stable
sudo make
sudo make install
```> Windows:
using Cygwin: https://www.jianshu.com/p/28960f5b1464## Install
``` bash
# git clone
# create virtual env
python3 -m venv venv
source venv/bin/activate
# install python modules
pip3 install -r requirements.txt
```Set redis server address in `/config.py`, default is:
`REDISTOGO_URL = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')`## Start up
```
# start Redis server
redis-server &
# run rq worker
python manage.py runworker
# run http server in anther terminal
python manage.py runserver
```
Bingo! Check app in your web browser at: http://localhost:5000## deploy to Heroku Server
ready for deploy to [Heroku](https://www.heroku.com)
`Procfile`, `heroku.sh` and `runtime.txt` are included. It will use one dyno to run both worker and http server.
```
create app in heroku
choose "REDISTOGO" or "Heroku REDIS" from resource
git push to heroku
configure env. variables
```
refer to: https://devcenter.heroku.com/articles/getting-started-with-python## Expansion
For production app, you can easily expand functions as you wish, such as:
- Flask_Compress
- Flask_Cache
- Flask_Admin
- Flask_Security
- [flask-template-advanced](https://github.com/kevinqqnj/flask-template-advanced)> For a detailed explanation on how things work, check out the [guide (CHN)](https://www.jianshu.com/p/f37871e31231).