Skip to content

Instantly share code, notes, and snippets.

@mdonkers
mdonkers / server.py
Last active November 15, 2024 20:01
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@danielmt
danielmt / commit.py
Last active March 14, 2022 16:49
pygit 2 snippets - most examples assume using a bare repository.
import pygit2
# open existing repository
repo = pygit2.Repository(pygit2.discover_repository('test_repos'))
# check if repos is newly created
if repo.head_is_unborn:
tb = repo.TreeBuilder()
parent = []
else: