News for hackers. Stuff that matters.

Show HN: Run a Python Flask HTTP Server in AWS Lambda (w/Poetry)

https://github.com/scaffoldly/scaffoldly-examples/tree/python-flask-poetry

Scaffoldly allows you to run any HTTP server inside AWS Lambda. It requires no code changes to your existing server and a simple configuration in the project's pyproject.toml. Deployments can be done locally or in GitHub Actions.

In this example, we're running a Flask server in AWS Lambda, and the scaffoldly toolchain handles packaging, deployment, and routing of AWS Lambda HTTP requests.

( 4 comments | on HN )
Re:Show HN: Run a Python Flask HTTP Server in AWS Lambda (w/... by billconan on Tuesday October 15, 2024 @08:53AM (#41848052)
it uses the port 5000, can lambda open any port?
Re:Show HN: Run a Python Flask HTTP Server in AWS Lambda (w/... by cnuss on Tuesday October 15, 2024 @09:18AM (#41848273)
Yup! Change the `handler` and `start` command:

``` handler = "localhost:5000" ... start = "poetry run flask --app flask_poetry run -p 12345" ```

Re:Show HN: Run a Python Flask HTTP Server in AWS Lambda (w/... by billconan on Tuesday October 15, 2024 @09:45AM (#41848551)
is this port publicly accessible? or the traffic is forwarded by lambda's interface?
Re:Show HN: Run a Python Flask HTTP Server in AWS Lambda (w/... by cnuss on Tuesday October 15, 2024 @11:21AM (#41849534)
It's not publicly accessible, per-se..., there's a reverse proxy I've written

1. There's a Function URL that then creates a Lambda HTTP Event

2. There's a reverse proxy in the container that converts the Lambda HTTP Event back into a HTTP Request

3. Then the HTTP Respose is transformed back into a Lambda HTTP Event Response

@billconan if you'd like, join my Discord and I'd be happy dive into details and/or provide more docs: https://scaffoldly.dev/community