Flask + EsiPy Example
This project is a small ready to work example on how to use EsiPy with Flask.
The following libraries are used:
- Flask for the webapp part
- EsiPy for the ESI API
- Flask-Login for the login / session process
- Flask-SQLAlchemy and SQLAlchemy for the database part
- Flask-Migrate for the migration commands
You will also require:
- Virtualenv to setup virtualenv
- Depending on the database you want to use, the required libraries (by default this example uses SQLite, which is embedded in Python)
Also, this example is made with Python 2.7, it might works with Python 3, but you may have to correct some lines of code
Get and init the project
- Clone the repository on your system
git clone https://github.com/Kyria/flask-esipy-example.git
- Create a virtualenv
cd flask-esipy-example
virtualenv venv
source venv/bin/activate
- Install requirements
pip install -r requirements.txt
- Setup the FLASK_APP environment variable
export FLASK_APP=app.py
Create your app in https://developers.eveonline.com
- Go to https://developers.eveonline.com
- Login and go to
manage applications
- Create a new application
- Fill all the fields
Requirements:
- For the scope, you will need
esi-wallet.read_character_wallet.v1
for this example - The callback URL must be
http://<SOME_IP_OR_DOMAIN>:<SOME_PORT>/sso/callback
APP Configuration
- Copy and rename the
config.dist
inconfig.py
- Edit it.
PORT = <SOME_PORT>
HOST = '<SOME_IP_OR_DOMAIN>'
SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db' # this is your database connection informations http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
# Fill these lines with the data you get from https://developers.eveonline.com
ESI_SECRET_KEY = '' # your secret key
ESI_CLIENT_ID = '' # your client ID
How to start everything
First, you will need to run the migration to create the required user table
flask db upgrade
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> fab636b98bc7, create_user_table
Run the app
python app.py
- Restarting with stat
- Debugger is active!
- Debugger PIN: 206-933-487
- Running on http://localhost:5015/ (Press CTRL+C to quit)
And now you can connect to http://localhost:5015/ to see it working (if you kept default configs)