Skip to main content

FastAPI-style Gemini Protocol Framework

Project description

FastGemini

A FastAPI-style framework for building Gemini protocol servers in Python.

Features

  • 🚀 FastAPI-style decorators - Define routes with familiar @app.route() syntax
  • 📦 Router support - Organize routes with GeminiRouter (like APIRouter)
  • 🔧 Path parameters - Extract values from URLs: /user/{username}
  • Async/await - Built on asyncio for high-performance async I/O
  • 🛡️ TLS/SSL - Native client certificate support
  • 🎯 Type hints - Full Pydantic integration for request/response models

Installation

pip install fastgemini

Quick Start

from fastgemini import GeminiApp, success
from fastgemini.schema import GeminiRequest, GeminiResponse

app = GeminiApp(
    certfile="path/to/cert.cer",
    keyfile="path/to/key.key",
)

@app.route("/")
async def index(request: GeminiRequest) -> GeminiResponse:
    return success("# Welcome to Gemini!\n")

@app.route("/hello/{name}")
async def hello(request: GeminiRequest) -> GeminiResponse:
    name = request.path_params["name"]
    return success(f"# Hello, {name}!\n")

if __name__ == "__main__":
    app.run()

Using Routers

from fastgemini import GeminiApp, GeminiRouter, success

app = GeminiApp(
    certfile="path/to/cert.cer",
    keyfile="path/to/key.key",
)
users = GeminiRouter(prefix="/users")

@users.route("/")
async def list_users(request):
    return success("# Users\n=> /users/alice Alice\n")

@users.route("/{username}")
async def get_user(request):
    return success(f"# User: {request.path_params['username']}\n")

app.include_router(users)

Response Helpers

from fastgemini import success, redirect, not_found, input_required, error

# Success with body
success("# Hello World\n")

# Redirects
redirect("/new-location")
redirect("/permanent", permanent=True)

# Errors
not_found("Page not found")
error("Something went wrong")

# Input prompts
input_required("Enter your name:")
input_required("Enter password:", sensitive=True)

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

fastgemini-0.1.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

fastgemini-0.1.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file fastgemini-0.1.3.tar.gz.

File metadata

  • Download URL: fastgemini-0.1.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastgemini-0.1.3.tar.gz
Algorithm Hash digest
SHA256 deda56a24aa127529e7420d7b3a2cd4620d9d4d705a1e19e512c7e8c602b9dfc
MD5 fd4f31997a7c035b65c90fbb4fa2cbde
BLAKE2b-256 35bad66f48a1e05a144aba680505d2897c881b3015793455b50bec8c175e826c

See more details on using hashes here.

File details

Details for the file fastgemini-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fastgemini-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastgemini-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72c3d790d3e8dbad11586cff53c7d7bbc8b4c1662bb0bae83b026cbd967fbba2
MD5 57f7ca9a112696ab2daa9a927f6e77ce
BLAKE2b-256 b1524167b151c0addfd3300178f1e24ffbfca0f07db5806c952f242c1fa17fad

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