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.2.tar.gz (9.0 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.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastgemini-0.1.2.tar.gz
  • Upload date:
  • Size: 9.0 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.2.tar.gz
Algorithm Hash digest
SHA256 fecd21d4f25fcac18650a11012e106278d39ff0ed3fba58e66af630fbd31c685
MD5 68d4ffc43a2c45304de277d8831aadf7
BLAKE2b-256 2cc5c35c6f6c4c6eaa3f82ef5dfacd3851c7de964dc030e805ff16c46288557b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastgemini-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f0872c8eed55d50d6493565b3640b4a3710682bfad061efe711bd96af4650bc
MD5 f896c89d1caa24335aea40cb648399fb
BLAKE2b-256 e4273545459c3df5b3ef4aba1ee58d71c5d12839e421a4a0f43568c9ec0ff01f

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