Skip to main content

Simple feedback collection for Air/FastAPI apps

Project description

AirFeedback

Simple feedback collection for Air/FastAPI apps.

Installation

pip install airfeedback

or with uv:

uv add airfeedback

Usage

import air
from airfeedback import AirFeedback
from sqlalchemy.ext.asyncio import AsyncSession

# Define your save callback
async def save_feedback(user_id: int, text: str, route: str | None):
    # Your save logic here (DB, file, API call, etc.)
    feedback = Feedback(user_id=user_id, text=text, route=route)
    async with AsyncSession(engine) as session:
        session.add(feedback)
        await session.commit()

# Initialize AirFeedback
feedback = AirFeedback(on_save=save_feedback)

# Register the route
app = air.Air()

@app.post("/feedback")
async def submit_feedback(request: air.Request, user: CurrentUser):
    return await feedback._submit_handler(request, user)

# In your UI - unstyled by default
feedback.button()
feedback.modal()

# With DaisyUI styling
feedback.button(class_="btn btn-ghost btn-sm")
feedback.modal(
    modal_class="modal-box",
    title_class="font-bold text-lg mb-4",
    textarea_class="textarea textarea-bordered w-full mb-4 min-h-32",
    submit_class="btn btn-primary",
    cancel_class="btn ml-2"
)

# With custom CSS
feedback.button(class_="my-feedback-btn")
feedback.modal(
    textarea_class="my-textarea", 
    submit_class="my-submit-btn"
)

Configuration

AirFeedback accepts the following parameters:

Parameter Type Default Description
on_save Callable[[int, str, str|None], Any] Required Async callback to save feedback. Receives user_id, text, and route
route_path str /feedback URL path for feedback submission
button_text str 💬 Feedback Text displayed on feedback button
success_message str ✓ Thanks for your feedback! Message shown after successful submission
error_message str Feedback cannot be empty Message shown when validation fails

Methods

button(class_="", **kwargs)

Returns a feedback button component. The button automatically captures the current route when clicked.

Parameters:

  • class_: CSS classes to apply to the button
  • **kwargs: Additional HTML attributes

modal(modal_class="", form_class="", textarea_class="", submit_class="", cancel_class="", title="Share Your Feedback", title_class="", placeholder="...")

Returns a feedback modal component.

Parameters:

  • modal_class: CSS classes for modal container
  • form_class: CSS classes for form element
  • textarea_class: CSS classes for textarea
  • submit_class: CSS classes for submit button
  • cancel_class: CSS classes for cancel button
  • title: Modal title text (set to None to hide)
  • title_class: CSS classes for title
  • placeholder: Textarea placeholder text

Features

  • Database Agnostic: Uses callback pattern - bring your own storage
  • Framework Agnostic CSS: Unstyled by default, works with any CSS framework
  • Route Tracking: Automatically captures the page URL where feedback was submitted
  • User Flexible: Works with any user object that has an id attribute

License

MIT License - see LICENSE file for details

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

airfeedback-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

airfeedback-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file airfeedback-0.1.1.tar.gz.

File metadata

  • Download URL: airfeedback-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for airfeedback-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cbfde9fe6e7c7705e6e4b635ba543cf646a86ab4ca3d3d75044d82fc9628d7b4
MD5 3ad5498fe02a838899fd49454a7a4d77
BLAKE2b-256 b5b61ab3efaa88c02df304a5c33bdc21d94f1d769edf6eef02b9b3f0f9486b54

See more details on using hashes here.

File details

Details for the file airfeedback-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airfeedback-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e645acbdb211b5a505306cc3d3d33d046f547b230b68b7e3ce097e0042772fdc
MD5 15d2d339705e97c82418b60d790c7fb6
BLAKE2b-256 0da23fb8e615cec8e1532c03662fe3b7bd3006a099b157e5f7afecd224e8196d

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