1.0.1 ā€¢ Published 4 years ago

minimal-flask-preact v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

minimal-flask-preact

Build Status npm npm License

This package generates a minimalistic template for building a full-stack web application with Flask and Preact.

šŸ”„ Features

šŸ’ Getting Started

First, install the package from npm.

npm install -g minimal-flask-preact

After downloading, you can create a new project with the following command.

minimal-flask-preact create my-project

šŸ“‹ Project Structure

Your project directory should now look like this.

tree my-project
my-project
ā”œā”€ā”€ jest.config.js
ā”œā”€ā”€ package.json
ā”œā”€ā”€ public
ā”‚Ā Ā  ā””ā”€ā”€ index.html
ā”œā”€ā”€ server
ā”‚Ā Ā  ā”œā”€ā”€ config.py
ā”‚Ā Ā  ā”œā”€ā”€ requirements.txt
ā”‚Ā Ā  ā”œā”€ā”€ routes
ā”‚Ā Ā  ā”‚Ā Ā  ā””ā”€ā”€ hello_world.py
ā”‚Ā Ā  ā”œā”€ā”€ server.py
ā”‚Ā Ā  ā””ā”€ā”€ tests
ā”‚Ā Ā      ā””ā”€ā”€ test_hello_world.py
ā”œā”€ā”€ src
ā”‚Ā Ā  ā”œā”€ā”€ __tests__
ā”‚Ā Ā  ā”‚Ā Ā  ā””ā”€ā”€ hello_world.test.tsx
ā”‚Ā Ā  ā”œā”€ā”€ app.tsx
ā”‚Ā Ā  ā”œā”€ā”€ components
ā”‚Ā Ā  ā”‚Ā Ā  ā””ā”€ā”€ button.tsx
ā”‚Ā Ā  ā”œā”€ā”€ store
ā”‚Ā Ā  ā”‚Ā Ā  ā””ā”€ā”€ store.tsx
ā”‚Ā Ā  ā””ā”€ā”€ views
ā”‚Ā Ā      ā””ā”€ā”€ hello_world.tsx
ā”œā”€ā”€ tsconfig.json
ā”œā”€ā”€ webpack.dev.js
ā””ā”€ā”€ webpack.prod.js

šŸš€ Frontend

To initialize your project use npm init.

cd my-project && npm init
npm install

You can start the webpack development server with this command.

npm run dev

To create a javascript bundle file for production use the provided script build.

npm run build

šŸ¤– Backend

It is a good practice to create a virtual environment when working on the backend. You can create an environment in Python with python -m venv {name}.

cd server && python3 -m venv venv
source venv/bin/activate

Use pip to install the related dependencies for the backend.

pip install -r requirements.txt

A Flask app relies on some environment variables which must be set in order to safely deploy the application on a public server.

export SECRET_KEY=XXX
export APP_SETTINGS=config.DevelopementConfig

To start the Flask server call server.py.

python server.py