File: on_startup.py

package info (click to toggle)
python-hug 2.6.0-2.4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,072 kB
  • sloc: python: 8,938; sh: 99; makefile: 17
file content (23 lines) | stat: -rw-r--r-- 429 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Provides an example of attaching an action on hug server startup"""
import hug

data = []


@hug.startup()
def add_data(api):
    """Adds initial data to the api on startup"""
    data.append("It's working")


@hug.startup()
def add_more_data(api):
    """Adds initial data to the api on startup"""
    data.append("Even subsequent calls")


@hug.cli()
@hug.get()
def test():
    """Returns all stored data"""
    return data