You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

sveltekit-modal

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sveltekit-modal

Write Python endpoints in SvelteKit using Modal

1.0.13
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

imageimage

sveltekit-modal

Write Python endpoints in SvelteKit using Modal.

Why

  • Start deploying Python endpoints in just a few steps
  • GPU support for an entire ML Stack in your SvelteKit app
  • Integrates completely, write +server.py just like your +server.js files
  • Deploy the rest of your app anywhere, with SvelteKit's adapters for Vercel, Netlify, Cloudflare, etc.
  • Severless Python with ease

Add to your 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

Keywords

sveltekit-modal

FAQs

Package last updated on 15 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts