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 Trio 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.1.tar.gz (8.9 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.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastgemini-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.tar.gz
Algorithm Hash digest
SHA256 3aeb1dbaf94e37514c9757c818321f3afb6011cbfd764d2fe6157193a28cfe7d
MD5 7a40973f8db693f3173a61811f251faa
BLAKE2b-256 371f63b1706393e774195591143c1a9794c40a40ac5506197ca11e2b2c7cb5c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastgemini-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17b82e51d0ce41448e4e8238a109c2b2568f771640548b82e2df91c091440ef7
MD5 d641f2936f0f977a693ed44ef526ddea
BLAKE2b-256 4330b4d51d8e5d33042695ed17d942de04954efaedbbf4f76a3c7b7ee5eafd4c

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