Skip to main content

FastAPI visitor statistics with middleware and stats page

Project description

fastapi-stats-page

usage

from fastapi import FastAPI
from fastapi_stats_page import StatsRouter, TrackVisitsMiddleware

app = FastAPI()

app.include_router(StatsRouter(title="Statistics of website").router)

app.add_middleware(TrackVisitsMiddleware)

@app.get("/")
async def homepage():
    return "hello world"

this will save visitors ip and user agens to a list

you can also save visitors to a file by doing this

from fastapi import FastAPI
from fastapi_stats_page import StatsRouter, TrackVisitsMiddleware

app = FastAPI()

app.include_router(StatsRouter(title="Statistics of website", get_from="users.txt").router)

app.add_middleware(TrackVisitsMiddleware, save_to="users.txt")

@app.get("/")
async def homepage():
    return "hello world"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_stats_page-0.1.6.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_stats_page-0.1.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_stats_page-0.1.6.tar.gz.

File metadata

  • Download URL: fastapi_stats_page-0.1.6.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for fastapi_stats_page-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d03f8ad342086113a1498c02a30fe6b7c44f93eeb35f72c3610c163b16957d78
MD5 0892f2a7da4ab07f60c04950ed847189
BLAKE2b-256 82a37992f0d487d44b708daa61ac6e15648f9c9d36b2a922f5958382c00ba834

See more details on using hashes here.

File details

Details for the file fastapi_stats_page-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_stats_page-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 60c2ce46e7689738d6651941afddd66259d03ea8f4f91ac563e6984d747ad215
MD5 2248e6b57721280c3430e369ff8e3994
BLAKE2b-256 2e074d08cb85a7533f83f29fcd1afdb606a93e9fc09fa0cb8e247892763d4c47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page