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.gitpipenv installcd web_src/
npm installRun in production mode (no Vue or FastAPI auto-reload)
pipenv run python main.pyRun in development mode (with Vue and FastAPI auto-reload)
export DEBUG=1 && pipenv run python main.pyOr on Windows
set DEBUG=1 ; pipenv run python main.pypipenv run python build.pyThe distributable .zip file will be in the build/dist/ folder.
- The
web_src/directory is the root directory for theVueapp. It is mounted at/in theFastAPIapp when running in production mode. - When in development mode, the
Vueapp is served byViteand theFastAPIapp is served byUvicorn. TheVueapp is mounted at/and theFastAPIapp is mounted at/api/. In this mode,FastAPImust be running on port 8080 so thatViteserver could proxy the requests to it.
- The Vue 3 app title will be set to the
FastAPItitle (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. FastAPIrouters should be added inviews/folder, sinceFastAPIrequires 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.tsfile inweb_src/src/directory. You can add your ownTypescripttypings here. - Executables (exe, dll, etc.) should be added to
executables/folder. They will be bundled and added to executable path when running the app.