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.0.tar.gz (8.4 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.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastgemini-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 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.0.tar.gz
Algorithm Hash digest
SHA256 c561528b3d42d7aa33848a1c2d405fc0b66d92e7bf9eae20f7c680c1484642d7
MD5 db1901747c3a6c3919263e9aa0b135f2
BLAKE2b-256 70ecc9b82600ca4b768246026f1e62161a04a4b3523eb2e1b398529c635122d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastgemini-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e618301e815842d55e920a2dd98d7781da2ce9fc8058b77105e891cc28d632e9
MD5 90a1b726f465e9b4738a076fa62a8d40
BLAKE2b-256 27ad40c351de4dce09acce3b48bc549684150b76146da3a7542a15a2fe4d7b31

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