<@ULVA73B9P> what is the "webserver" option in flo...
# marvin-in-the-wild
d
@Marvin what is the "webserver" option in flow.serve for? give an example
m
The "webserver" option in
flow.serve
specifies whether to spin up an auto-refreshing web-based dashboard when serving the flow. This is helpful for monitoring and whether to start a web server to serve the deployed flow. Here is an example of using `flow.serve`:
Copy code
python
import time
from prefect import flow, task
from pydantic import BaseModel, Field

class Data(BaseModel):
    key: str
    value: dict = Field(default_factory=dict)

@task
def fetch_data_for_key(key: str) -> Data:
    """A task that simulates fetching data from some source"""
    return Data(key=key, value={"data": "some data"})

@task
def process_data(data: Data) -> Data:
    """A task that simulates processing data"""
    print(f"Processing {data!r} (I swear)")
    time.sleep(3)
    return data

@flow
def work_i_need_to_do_sometimes(keys: list[str]):
    """Work you might need to do ever so often"""
    
    raw_data_futures = fetch_data_for_key.map(keys)

    process_data.map(raw_data_futures)

if __name__ == "__main__":
    work_i_need_to_do_sometimes.serve(
        name="sporadic-deployment",
        parameters={"keys": ["foo", "bar", "baz"]},
        webserver=True # This will spin up the web-based dashboard
    )
For more details, refer to the official documentation: Flow Serve Example.