Tiny flask application for automated link shortening via vk.cc service.
Takes a .xlsx
file with links and returns the same file but with shortened links alongside the old ones.
-
Clone this repository:
git clone https://github.com/rulen111/vkcc-auto.git
-
Create virtual environment and install requirements:
pip install -r requirements.txt
-
Configure the application:
Application's default settings can be found in./vkcc_auto/config
module. Since this application sends request to VK API, along with flask app'sSECRET_KEY
user must provide a valid VK API access token of any type. One way to do that is to create a separate config file with app's secret key and an access token (i.e.my_config.cfg
) and set an environment variableVKCCAUTO_SETTINGS
pointing to that file.
Config file:SECRET_KEY = "<your secret key>" TOKEN = "<your access token>"
Setting env variable:
export VKCCAUTO_SETTINGS=/path/to/my_config.cfg
-
Configure celery:
This application uses Redis by default. Therefore, you need to have redis backend installed on your system in order to run this application. The easiest way is to use docker:docker run -d -p 6379:6379 redis
You can use any compatible message broker, but make sure to change the celery configuration in
./vkcc_auto/config
:CELERY = dict( broker_url="<your broker url>", result_backend="<your broker url>", )
- Make sure your app is configured
- Run celery backend:
Startup your message broker (redis by default) and run the Celery worker server using./make_celery.py
:
celery -A make_celery worker -l info -P solo
- Deploy application:
Usingflask
built-in development server:
Or usingflask --app vkcc_auto run
gunicorn
:gunicorn -b 0.0.0.0:8000 -w 4 'vkcc_auto:create_app()'
- The application has only one page and it's pretty straightforward. Choose a
.xlsx
file with links, press SUBMIT button and wait for an output file download. Main page also provides a dynamic progress bar for tracking task progress.