A practical example of a web app using Flask serving a Svelte app, acting as the backend server. The frontend is constructed using Svelte with webpack as the bundler.
# Windows
python -m venv env
# Linux, WSL or macOS
python3 -m venv env
# Windows
env/Scripts/activate
# Linux, WSL or macOS
source env/bin/activate
pip install -r requirements.txt
When running this Flask application for the first time, make sure to create the database tables before starting the server (This should only be done once.) This can be done by running the following command:
python create_db.py
Run the following to start the Flask server.
python server.py
Open a new terminal and run the following:
cd frontend;
then npm install
to install the Svelte frontend dependencies.npm run dev
to start the Svelte frontend.Open localhost:8080
in your browser to see the app.