Hello World
Here’s a simple “Hello, World!” example using Hyperscript with the Convergence backend.
This and all other examples assume you have already set up your Convergence API key as an environment variable named CONVERGENCE_API_KEY.
from hyperscript import Hyperscriptfrom hyperscript.convergence import Convergenceimport os
# Define the function we want run in the clouddef hello_world(): return "Hello, World!"
async def main(): # Set up Convergence as our backend convergence = Convergence(api_key=os.getenv("CONVERGENCE_API_KEY"))
# Initialize Hyperscript with Convergence's storage and event systems async with Hyperscript( storage=convergence.storage, events=convergence.events ) as hs: # Run the hello_world function in the cloud task = await hs.run(fn=hello_world, args=[], executor=convergence.executor)
# Retrieve and print the result async for result in task.results(): print(f"Got result: {result}")
# Hyperscript leverages asyncio, so we need to run our main function in an event loopif __name__ == "__main__": import asyncio
asyncio.run(main())