This example demonstrates the core concept of a serverless function (Function-as-a-Service) using a simple Python HTTP server. It simulates small, independent code units that are triggered by HTTP requests, process input, and return a response, without requiring explicit server management from the developer's perspective. The functions are stateless and designed for specific tasks, mirroring how serverless platforms like AWS Lambda or Azure Functions operate.
python
- Save the code as
main.py. - Run the script from your terminal:
python main.py - Test the simulated functions using
curl:curl http://localhost:8000/hello?name=DevToUsercurl http://localhost:8000/infocurl -X POST -H "Content-Type: application/json" -d '{"input": "sample data"}' http://localhost:8000/process_data
This example accompanies the Turkish article: Open Serverless v4 ile Sunucusuz Geleceğe Adım Atın: Yenilikler ve Uygulama Rehberi.
MIT — see LICENSE.