Welcome to Flask-Svelte, a python package that integrates Svelte with Flask. This integration brings together the best of both worlds: Svelte's reactive frontend capabilities and Flask's robust backend, providing a seamless experience for web application development.
Note: This package is still in development. The API is subject to change.
render_template
function extends Flask's capability, allowing direct data integration into Svelte templates for dynamic content rendering.pip install flask-svelte
flask-svelte create <project_name>
cd <project_name>
npm install
npm run dev
flask-svelte add-page <template_name>
Generates Svelte files in svelte/<template_name>
. Edit them and see the changes in the browser.
Note: The npm run dev
command must be restarted for new templates to be recognized.npm run build
for deployment readiness. Post-build, the svelte
directory is optional.flask.render_template
with flask_svelte.render_template
for enhanced data passing. Example:from flask_svelte import render_template
from app import app
@app.route('/')
def index():
return render_template('index.html', name='World')
{{ app.data["key"] }}
. Example:<h1>Hello {{ app.data["name"] }}!</h1>
render_template
Functionrender_template
for integrating Python and JavaScript.app.data
Object{{ app.data["key"] }}
.Create a New Project:
flask-svelte create <project_name>
Sets up a new Flask-Svelte project environment.
Add a New Template:
flask-svelte add-page <template_name>
Adds a new Svelte template to your project, creating necessary files in svelte/<template_name>
.