Creating Wishlist2Text website – Part 1

Hello, I am going to describe how I create website. I use flask for it.

Start by creating virtualenv. Make sure virtualenv package is installed. 

virtualenv venv
source venv/Scripts/activate

# Install flask
pip install flask

Create which will be used to start the app. The filename should be because this is the filename which google app engine expects. App engine I am using for hosting.
At the top of the file, I am importing create_app function. And run the app.  The function will be created later.

from wishlist2text import create_app

app = create_app()

if __name__ == "__main__":

As the next step, I need to create a wishlist2text package, Create a folder with the same name, and inside of this folder create file. This file lets python know that wishlist2text folder is a package.
In the init file I will create create_app function and init flask Class. Als I am going to use flask blueprints. Blueprint allows making my app modular. Create rest of required folder, static for js, CSS and images, templates for HTML and scan_wishlist. Scan wishlist will store my first flask blueprint. Let’s back to At the top, I need to import Flask and Blueprint class, and flask config, which will be created later.

from flask import Flask, Blueprint
from wishlist2text.scan_wishlist.api import SteamWishlist

Now I am ready to create create_app function. In the function instance of Flask class need to be created and specified which config is used. Next blueprint needs to be imported and registered (Will be created later). In the end, flask instance needs to be returned.

def create_app(config_class=Config):
    app = Flask(__name__)

    from wishlist2text.scan_wishlist.routes import wishlist


    return app

I am importing Config class but it not created. Let’s fix it. Create in the root of the wishlist2text folder, where is located In this file, I will store all my app config. Example of config.

import os

class Config(object):
    SECRET_KEY = os.environ.get("SECRET_KEY") or "secret_key"
    API_KEY = os.environ.get("API_KEY")

API links will stay the same, but to make an app work SECRET_KEY and API_KEY environment variables need to be created. SECRET_KEY – Set the secret key to some random bytes. Keep this really secret! and API_KEY is steam API token. Can be generated here. In the next post, I will explain how to create flask blueprint. Stay tuned.