This is a template for a Python Vue 3 app. It uses Pipenv for python dependencies and Vite for Vue 3 development. For Backend, it uses FastAPI. For Frontend, it uses Vue 3 with TailwindCSS and TypeScript.
git clone https://github.com/KhanhhNe/python-vue3-app.git
pipenv install
cd web_src/
npm install
Run in production mode (no Vue
or FastAPI
auto-reload)
pipenv run python main.py
Run in development mode (with Vue
and FastAPI
auto-reload)
export DEBUG=1 && pipenv run python main.py
Or on Windows
set DEBUG=1 ; pipenv run python main.py
pipenv run python build.py
The distributable .zip
file will be in the build/dist/
folder.
- The
web_src/
directory is the root directory for theVue
app. It is mounted at/
in theFastAPI
app when running in production mode. - When in development mode, the
Vue
app is served byVite
and theFastAPI
app is served byUvicorn
. TheVue
app is mounted at/
and theFastAPI
app is mounted at/api/
. In this mode,FastAPI
must be running on port 8080 so thatVite
server could proxy the requests to it.
- The Vue 3 app title will be set to the
FastAPI
title (you can change this inapp/app.py
). The FastAPI server also exposes useful OpenAPI urls (e.g./api/docs
,/api/redoc
,/api/openapi.json
) that you can use in the Vue app. FastAPI
routers should be added inviews/
folder, sinceFastAPI
requires a specific order of routers, middlewares, and dependencies to work properly, so only change them if you know what you are doing.- There are an empty
typings.d.ts
file inweb_src/src/
directory. You can add your ownTypescript
typings here. - Executables (exe, dll, etc.) should be added to
executables/
folder. They will be bundled and added to executable path when running the app.