Skip to content

libeanim/refuelking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Refuelking

This is a simple webapp to find the nearest and cheapest gas station based on the Tankerkoenig API and the CC by 4.0 license for the IT-Talents' monthly competition. All maps in this webapp are rendered through the OpenLayers library and the frontend of this app is in german.

Click here for a working demo.

Requirements

  • python3
  • virtualenv
  • pip

Python dependencies

These packages can be installed via pip, see installation instructions below.

  • flask
  • flask-sqlalchemy
  • bokeh
  • geocoder

Installation

  1. Clone the repository:

    git clone https://github.com/libeanim/refuelking.git
  2. Create a virtual environment and activate it:

    virtualenv -p python3 my_environment
    source my_environment/bin/activate
  3. Use pip to install required packages in the virtual environment:

    cd refuelking
    pip install -r requirements.txt

Run Test Server

This is a simple explanation to run this website on a local flask test server.

  1. After you finished the installation procedure, execute the init_all.py script in the activated virtual environment:

    python3 init_all.py

    This will generate the configuration file and requires your Tankerkoenig api key. It also initialises a sqlite database in the module directory called sample.db

  2. Execute now the run_debug.py script to start the server:

    python3 run_debug.py
  3. That's it! You should now be able to access the website on http://127.0.0.1:5000/.

Deployment

There are many ways to deploy a Flask application. Choose your favorite or mandatory way according to your webspace provider.

Then before you start the application set the following two environment variables:

  • Set the app configuration to production mode:

    export APP_CONFIG="config.ProductionConfig"
  • Set the url to your database:

    export DATABASE_URL="mysql+oursql://username:password@server/database"

    More information on the sqlalchemy database url format can be found here.

    Hint: A working engine for mysql and python3 is oursql

Before the first run make sure the configuration and database has been created. You can do that by executing the init_all.py script with the correct value for the environment variable DATABASE_URL.