Run SvelteKit frontend + FastAPI backend on Deta Space.
The root of the project contains the Spacefile and two subdirectories, each running one Micro.
The svelte
directory contains the SvelteKit frontend. The fastapi
directory contains the FastAPI backend.
Spacefile
/svelte
/src
/static
package.json
...
/fastapi
main.py
requirements.txt
...
- Navigate into the fastapi directory and create a virtual env with
python3 -m venv .venv
. - Install all dependencies with
pip install -r requirements.txt
. - Navigate into the
svelte
directory and runnpm install
- From the top level directory, run
space dev
to start both servers through a single port. - Develop away
Your fastapi
server will now be served on the /api
route, which is set in the Spacefile
. Try visiting the development server's /api
route to see it in action. The /
route will serve the SvelteKit frontend.
- Run
space new
. - From the top level directory, run
space push
(first runspace new
if you have no Space project).