Discuss Scratch

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

Yes you read it correctly

Spylt (pronounced spilt, combination of Svelte and Python) is a connector for Python HTTP backends and Svelte frontends. Simple Python functions can be turned into web APIs which can be directly called from Svelte code under a single codebase.

Normally, if you wanted to combine an API and a frontend framework, you would have to separate the apps into different codebases and different repositories. (which a lot of apps have to do)

The ideal solution would be to simply store frontend code in a single application, similar to how classic monolith sites work. Instead of storing HTML pages however, it would use Svelte pages, which allow for better modularity and more reactivity.

This is what Spylt aims to do. Spylt works best for demo apps (like Streamlit or Gradio) that need more control over JavaScript/CSS. Since Spylt also uses Svelte for the frontend, it can outperform libraries like Pynecone and Plotly Dash.

Read more at the GitHub repo (and consider starring it)
I've actually had this code sitting around since October of 2022 until I decided to fix it

Last edited by ajskateboarder (May 5, 2023 16:23:56)

DifferentDance8
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

DifferentDance8 wrote:

bigspeefpv: now what on god's green earth do you need this for
Making simple data visualizations when you don't want to write a seperate API
With this framework, APIs are written as plain functions which are then transpiled to server routes
DifferentDance8
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ajskateboarder wrote:

DifferentDance8 wrote:

bigspeefpv: now what on god's green earth do you need this for
Making simple data visualizations when you don't want to write a seperate API
With this framework, APIs are written as plain functions which are then transpiled to server routes
so basically flask but for svelte
ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

DifferentDance8 wrote:

ajskateboarder wrote:

DifferentDance8 wrote:

bigspeefpv: now what on god's green earth do you need this for
Making simple data visualizations when you don't want to write a seperate API
With this framework, APIs are written as plain functions which are then transpiled to server routes
so basically flask but for svelte
Yes? Also this uses Quart which supports ASGI
ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

Example:

from spylt import require_svelte
app = require_svelte("./src/App.svelte")
@app.backend()
def say_hello(name: str):
    return f"Hello {name}"
<!-- point ./src/App.py:app -->
<script>
    const say_hello = async (name) => { 
        request = await fetch(`/api/say_hello?name=${name}`)
        json = await request.json()
        return json.response
    }
    let greeting
    let name = "Bob"
</script>
<main>
    <input type="text" bind:value={name}>
    <button on:click={(async function() { greeting = await say_hello(name) })()}>Say hello</button>
    <p>{greeting}</p>
</main>
qloakonscratch
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

“man I can't wait to SpyIt”

“Wait what you are going to spy on me”

“wait what no-”
bigspeedfpv
Scratcher
500+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

sveltekit allows you to define api routes. is this supposed to be a python equivalent of that? if so kinda cool
ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

bigspeedfpv wrote:

sveltekit allows you to define api routes. is this supposed to be a python equivalent of that? if so kinda cool
Yeah I knew you could do that in SvelteKit
I made this because Python has a generally better ecosystem
ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

Bump
will_z_j
Scratcher
100+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

Welcome to Grand Theft Auto: The Movie (Director's Çut)
Déconseillé aux moins de 18 ans by Canal+
WojtekGame
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

will_z_j wrote:

-offtopic snip-
ArrowAced
Scratcher
7 posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ajskateboarder wrote:

Normally, if you wanted to combine an API and a frontend framework, you would have to separate the apps into different codebases and different repositories. (I'm looking at you Meower)

Wouldn't Meower still have to separate them due to the use of websockets?

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ArrowAced wrote:

ajskateboarder wrote:

Normally, if you wanted to combine an API and a frontend framework, you would have to separate the apps into different codebases and different repositories. (I'm looking at you Meower)
Wouldn't Meower still have to separate them due to the use of websockets?
Don't they also use HTTP
CST1229
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ajskateboarder wrote:

(#14)

ArrowAced wrote:

ajskateboarder wrote:

Normally, if you wanted to combine an API and a frontend framework, you would have to separate the apps into different codebases and different repositories. (I'm looking at you Meower)
Wouldn't Meower still have to separate them due to the use of websockets?
Don't they also use HTTP
It does (alongside said websocket).

Last edited by CST1229 (April 20, 2023 22:09:43)

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

Can people try out my framework and give thoughts? I haven't really done much testing outside of unit tests

Make sure to read the caveats before starting

Last edited by ajskateboarder (April 20, 2023 23:27:23)

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

b
ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

ajskateboarder
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

b
lolecksdeehaha
Scratcher
1000+ posts

Spylt: A Python/Svelte fullstack framework for demos and small sites

cool project but nobody here is going to use this since scratchers can't fathom full-stack development

Powered by DjangoBB