minimal-flask-preact v1.0.1
minimal-flask-preact
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-preactAfter 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 installYou can start the webpack development server with this command.
npm run devTo 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/activateUse pip to install the related dependencies for the backend.
pip install -r requirements.txtA 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.DevelopementConfigTo start the Flask server call server.py.
python server.py