Skip to main content

Handler for FastAPI apps in Yandex Cloud Functions

Project description

Yalambda

Yandex Cloud Functions handler for FastAPI applications

For what?

I was unable to launch applications written using the FastAPI framework in the form of Yandex cloud functions. So I had to develop an adapter to solve this problem.

Example

from fastapi import FastAPI
from ycfuncs import FastAPIHandler

# For local launch
app = FastAPI()


@app.get("/")
async def root():
    return 'Hello World!'

# Entry point for launch in Yandex cloud function 
handler = FastAPIHandler(app)

local launch

Install uv sync or pip install -r requirements.txt Run in terminal uv run fastapi dev --port=5004 or uvicorn main:app --port=5004

Yandex cloud functions launch

Set entry point to main.handler Request handler for a function in Python

Yandex Cloud ApiGateway

Now you can use Yandex Cloud ApiGateway like this:

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
servers:
- url: https://yourdomain.apigw.yandexcloud.net
paths:
  /some-prefix/{url+}:
    x-yc-apigateway-any-method:
      x-yc-apigateway-integration:
        payload_format_version: '0.1'
        function_id: your-function-id
        tag: $latest
        type: cloud_functions
        service_account_id: your-service-account
      parameters:
        - name: url
          in: path
          description: path
          required: true
          schema:
            type: string

And check curl -XGET https://yourdomain.apigw.yandexcloud.net/some-prefix/ - you should get "Hello World!". In this case {url+} is your APIRouter endpoints.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ycfuncs-25.8.7.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ycfuncs-25.8.7-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file ycfuncs-25.8.7.tar.gz.

File metadata

  • Download URL: ycfuncs-25.8.7.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for ycfuncs-25.8.7.tar.gz
Algorithm Hash digest
SHA256 8dffaed17a677ba7d1b8705ead38d481c3d31894788561de8e7ad0d758ad66da
MD5 51990bd46656922c2cb2faacefd85e07
BLAKE2b-256 a31ead63c14dbbe630223f0b79e81e3214789b41f4f8da2e2b937eb4047ff4d4

See more details on using hashes here.

File details

Details for the file ycfuncs-25.8.7-py3-none-any.whl.

File metadata

  • Download URL: ycfuncs-25.8.7-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for ycfuncs-25.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 78f13e6a63825eb13fa23dd15e314e96edb7177aad38920588b95a22559dabba
MD5 41b1c67be2446143c17fee9acc6ee3c0
BLAKE2b-256 e838cbe5c327630f14d1713d4b20db63e59094399a71dc819b6f8bef20d03ec3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page