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.7.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.7-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_stats_page-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 2f82592a8abf1e945238f088e203b2a8644b7f139d404284e2ca625490deb967
MD5 3ae4b62f473f28dfe8d2b58cbded0be8
BLAKE2b-256 05c7fae386c060f596e6935010b0ac80a2ebbf7f2264d215f7c38b6154d21757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_stats_page-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c14ca3a95e92ca2f9fb00906ccce33bcf88eb693da1127eadf720168f4d78311
MD5 5e2ae0af1eeba272fca90c177c4ad192
BLAKE2b-256 497b2c275c78507bcfcc0707c9edd97ba4cbc4660b6b8af2c37e6fc9833a2522

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