1.0.16 • Published 1 year ago

sveltekit-modal v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

sveltekit-modal

Write Python endpoints in SvelteKit using Modal.

Why

Add to your SvelteKit project

  • Open a new or existing SvelteKit Project
  • Install npm i -D sveltekit-modal
  • Sign up for modal.com, the serverless python platform. All users get $30 free monthly credits!
  • Update vite.config.js

    import { sveltekit } from '@sveltejs/kit/vite';
    import { defineConfig } from 'vite';
    
    import { sveltekit_modal } from 'sveltekit-modal/vite'; //Add this import
    
    export default defineConfig({
    		  plugins: [sveltekit_modal(), sveltekit()] //Add the `sveltekit_modal()` plugin
    });
  • Update svelte.config.js

    import adapter from '@sveltejs/adapter-auto';
    import { vitePreprocess } from '@sveltejs/kit/vite';
    
    /** @type {import('@sveltejs/kit').Config} */
    const config = {
    		  preprocess: vitePreprocess(),
    		  kit: {
    			  adapter: adapter(),
    			  moduleExtensions: [".js", ".ts", ".py"] //Add this line, to resolve +server.py endpoints
    		  }
    };
    
    export default config;
  • Create sveltekit_modal_config.py. The option stub_asgi is passed to Modal. This is where you can define GPU acceleration, secrets, and an Image for pip installs, etc. Explore their docs!

    import modal
    
    config = {
        'name': 'sveltekit-example',
        'log': False,
        'stub_asgi': {
            'image': modal.Image.debian_slim()
        }
    }
  • Update .gitignore, add !.env.production.

  • Write your endpoints! See an example here.

Use

  • Develop like a normal SvelteKit app, just npm run dev
  • Deploy all your python endpoints with one command, just npx sveltekit-modal deploy

Examples

The example_app/ directory contains an incredibly bare and demonstrates how to get it working.

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago