/Boilerplate

Scripts to create boilerplate code under different frameworks

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Boilerplate code generator

createboilerplate.sh is a bash script for generating boilerplate code for projects based on specific libraries and frameworks. It's intended to help kickstart projects by laying out the empty templates and take over the repetitive task of setting initial configurations.

Supported Libraries & Frameworks

Getting Started

Clone the repository to your local environment.

git clone https://github.com/alvii147/Boilerplate.git

It's convenient to set up an alias for the path to this script so it can be called from anywhere. Add the following line to .bashrc or .bashprofile to set up a permanent alias.

alias createboilerplate="/absolute/path/to/./createboilerplate.sh"

There are some dependencies within the individual projects, all of which are explored below.

Django

Django logo

Usage

createboilerplate [OPTIONS] django

Options

-p = project name

Requirements

Install Django, Django REST Framework, and Django CORS Headers.

pip3 install django djangorestframework django-cors-headers

Example Use

createboilerplate -p MyProject django

This creates a Django project and application. The application includes development and production settings, and an accounts app with a custom user model.

MyProject/
├── MyProject
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── dev.py
│   │   └── prod.py
│   ├── urls.py
│   └── wsgi.py
├── accounts
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
└── manage.py

To start using the application, set the appropriate environment variables.

# development/production environment
export MYPROJECT_DJANGO_ENV="<environment>"
# secret key
export MYPROJECT_DJANGO_SECRET_KEY="<secret key>"
# postgres settings
export MYPROJECT_POSTGRES_DB="<postgresql database name>"
export MYPROJECT_POSTGRES_USER="<postgresql username>"
export MYPROJECT_POSTGRES_PASSWORD="<postgres password>"
export MYPROJECT_POSTGRES_HOST="<postgres host name>"
export MYPROJECT_POSTGRES_PORT="<postgres port number>"
# email backend settings (only for production)
export MYPROJECT_EMAIL_HOST_USER="<host email address>"
export MYPROJECT_EMAIL_HOST_PASSWORD="<host email password>"

Once environment variables are set, Django server is ready to be run.

python3 manage.py runserver

In order to create and apply initial migrations (include those of the custom user), run migrations command.

python3 manage.py makemigrations
python3 manage.py migrate

Flask

Flask logo

Usage

createboilerplate [OPTIONS] flask

Options

-p = project name

Requirements

Install Flask and Flask SQLAlchemy.

pip3 install Flask Flask-SQLAlchemy

Install Flask SQLAlchemy (optional, required for setup database option).

pip install flask-sqlalchemy

Example Use

createboilerplate -p MyProject flask

This creates a boilerplate Python Flask application, with an HTML template, a CSS file and a SQLite3 database.

MyProject/
├── MyProject.py
├── static
│   └── styles.css
└── templates
    └── home.html

Set up environment variables.

export FLASK_APP_SECRET_KEY="<secret key>" 

Executing MyProject.py runs the basic Flask application on https://localhost:5000.

python3 MyProject.py

Flask Screenshot

Go

Go logo

Usage

createboilerplate [OPTIONS] go

Options

-p = project name
-u = github username

Requirements

Install Go from the official Go website

Example Use

createboilerplate -p MyProject -u Noobmaster69 go

This generates a boilerplate Go server that serves HTML templates using Go's built-in templating library, styled with Bootstrap. A Dockerfile is also generated to build and run the application inside a Docker container.

MyProject/
├── Dockerfile
├── go.mod
├── handlers
│   ├── home.go
│   ├── logging.go
│   └── templates.go
├── main.go
├── static
│   ├── css
│   │   └── styles.css
│   ├── images
│   │   └── gopher.png
│   └── js
│       └── index.js
└── templates
    ├── head.html
    ├── home.html
    ├── navbar.html
    └── scripts.html

Execute the go module to run the web server on https://localhost:8000.

go run .

Go Screenshot

PyQt6

Qt logo

Usage

createboilerplate [OPTIONS] pyqt6

Options

-p = project name

Requirements

Install PyQt6.

pip install pyqt6

Example Use

createboilerplate -p MyProject pyqt6

This creates a boilerplate PyQt5 script, MyProject.py. Running it starts a basic PyQt6 desktop application.

python3 MyProject.py

PyQt6 Screenshot