Fast Frappe
Use example to build serverless function using frappe framework.
- Author: castlecraft
- Repository: https://github.com/castlecraft/fast_frappe
- GitHub stars: 15
- Forks: 12
- License: NOASSERTION
- Category: Developer Tools
- Maintenance: Unmaintained
Install Fast Frappe
bench get-app https://github.com/castlecraft/fast_frappe
Add the Frappe Gems badge to your README
Maintain Fast Frappe? Paste this into your README:
[](https://frappegems.com/gems/apps/castlecraft/fast_frappe)
About Fast Frappe
Fast Frappe
FastAPI using Frappe Framework
Use example to build serverless function using frappe framework.
Prerequisites
- Core development happens with standard
bench start. - Already running
frappe-benchlike setup. - Connection to same mariadb, redis that the
frappe-benchconnects to. - Access to
sitesdirectory of thefrappe-bench - Valid site to set it as
SITE_NAMEenvironment variable.
Installation
Install as python app in frappe-bench python env
cd ~/frappe-bench
git clone https://github.com/castlecraft/fast_frappe apps/fast_frappe
./env/bin/pip install -e apps/fast_frappe
Serve
Using uvicorn
cd ~/frappe-bench
. ./env/bin/activate
# Execute app from sites directory
cd ~/frappe-bench/sites
# Set SITE_NAME to use for the function
SITE_NAME=function.local uvicorn fast_frappe.main:app --port 3000
Check Response
curl -s http://localhost:3000 | jq .
Containerized
Build
cd ~/frappe-bench/apps/fast_frappe
docker build -t fast_frappe:latest .
Run
docker run -v /path/to/sites:/home/frappe/frappe-bench/sites --publish 3000:3000 fast_frappe:latest
Description
The app consists of 2 files:
main.py:
import frappe
from typing import Optional
from fastapi import FastAPI
from fast_frappe.ctrl import init_frappe, destroy_frappe
app = FastAPI()
@app.get("/")
def read_root():
init_frappe()
available_doctypes = frappe.get_list("DocType")
settings = frappe.get_single("System Settings")
destroy_frappe()
return {
"available_doctypes": available_doctypes,
"settings": settings.as_dict(),
}
and ctrl.py:
import os
import frappe
def init_frappe():
site = os.environ.get("SITE_NAME", "test.localhost")
frappe.init(site=site)
frappe.connect()
def destroy_frappe():
frappe.destroy()
License
MIT
Related Developer Tools apps for Frappe & ERPNext
- Frappe — Low code web framework for real world applications, in Python and Javascript
- Frappe Docker — Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development
- Builder — Craft beautiful websites effortlessly with an intuitive visual builder and publish them instantly
- Bench — CLI to manage Multi-tenant deployments for Frappe apps
- Frappe Ui — A set of components and utilities for rapid UI development
- Press — Full service cloud hosting for the Frappe stack - powers Frappe Cloud
- Gameplan — Open Source Discussions Platform for Remote Teams
- Doppio — A Frappe app (CLI) to magically setup single page applications and Vue/React powered desk pages on your custom Frappe apps.