{"id":14974194,"url":"https://github.com/rodrobin/flask-server-timing","last_synced_at":"2025-10-02T02:31:31.695Z","repository":{"id":57430716,"uuid":"154376776","full_name":"rodrobin/flask-server-timing","owner":"rodrobin","description":"HTTP Server-Timing for Python-Flask","archived":false,"fork":true,"pushed_at":"2018-10-30T17:41:34.000Z","size":161,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-16T19:22:30.461Z","etag":null,"topics":["extension","flask","metrics","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"PammyS/server-timing-profiler","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodrobin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-23T18:22:05.000Z","updated_at":"2024-11-24T08:25:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rodrobin/flask-server-timing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrobin%2Fflask-server-timing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrobin%2Fflask-server-timing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrobin%2Fflask-server-timing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrobin%2Fflask-server-timing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrobin","download_url":"https://codeload.github.com/rodrobin/flask-server-timing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234929134,"owners_count":18908880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","flask","metrics","python"],"created_at":"2024-09-24T13:50:08.338Z","updated_at":"2025-10-02T02:31:31.019Z","avatar_url":"https://github.com/rodrobin.png","language":"Python","readme":"# Flask Server-Timing Header Extension\n\nA Flask extension to easily add the Server-Timing header to allow supported browsers to show backend performance metrics.\n\nFrom the [Mozilla Developer site](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing):\n\n\u003e The Server-Timing header communicates one or more metrics and descriptions for a given request-response cycle. It is used to surface any backend server timing metrics (e.g. database read/write, CPU time, file system access, etc.) in the developer tools in the user's browser\n\n\nThe Server-Timing specification is a [W3C draft](https://www.w3.org/TR/server-timing)\n\n## Installation\n\n```\npip install flask-server-timing\n```\n\nPython versions 2.7 and 3.x are supported with Flask from version 0.10.1.\n\n## Browser Support\n\nGenerally all newer, major browsers - excluding IE and Safari - support visualizing the Server-Timing header. For an up-to-date list with specific versions see the [Mozilla Developer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing#Browser_compatibility) site\n\n## Usage\n\n```python\nfrom flask import Flask\nimport time\n\n# Import extension\nfrom from server_timing import Timing\n\napp = Flask(__name__)\n\n# To initialize the extension simply pass the app to it. If the app is in debug\n# mode or the force_debug parameter is True an after-request handler will be added\n# to write the actual header.\nt = Timing(app, force_debug=True)\n\n\n@app.route(\"/examples\")\ndef examples():\n    # explicitly calling start and stop before and after - keys need to be identical\n    t.start('done and done')\n    time.sleep(0.3)\n    t.stop('done and done')\n\n    # context manager support to avoid having to call start and stop explicitly\n    with t.time('context'):\n        time.sleep(0.2)\n\n    # decorated with name being the key\n    named_decoration()\n    # decorated without name so the function is the key\n    unnamed_decoration()\n\n@t.timer(name='named')\ndef named_decoration():\n    time.sleep(0.4)\n\n@t.timer\ndef unnamed_decoration():\n    time.sleep(0.5)\n\n\napp.run(host=\"0.0.0.0\",port=8080)\n```\n\nThe `example/` directory also contains the following file showing how to time functions in other modules:\n\n```python\nimport time\n\n# before this file is imported make sure the extension has been initialized with the Flask app\nfrom server_timing import Timing as t\n\n\n@t.timer\ndef include():\n    time.sleep(0.1)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrobin%2Fflask-server-timing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrobin%2Fflask-server-timing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrobin%2Fflask-server-timing/lists"}