Created
April 23, 2017 15:40
-
-
Save insom/7cdeea2ee962e4403f11c7dca0367523 to your computer and use it in GitHub Desktop.
Teensy Tiny OStatus / Mastodon server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
@app.route("/.well-known/host-meta") | |
def hostmeta(): | |
return """<?xml version="1.0"?> | |
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> | |
<Link rel="lrdd" type="application/xrd+xml" template="https://insm.cf/.well-known/webfinger?resource={uri}"/> | |
</XRD>""", {'Content-Type': 'application/xrd+xml; charset=utf-8'} | |
@app.route("/.well-known/webfinger") | |
def wf(): | |
ct = '''application/jrd+json; charset=utf-8''' | |
d = { | |
"subject": "acct:insom@insm.cf", | |
"aliases": [ | |
"https://insm.cf/@insom" | |
], | |
"links": [ | |
{ | |
"rel": "http://webfinger.net/rel/profile-page", | |
"type": "text/html", | |
"href": "http://insm.cf/@insom" | |
}, | |
{ | |
"rel": "http://schemas.google.com/g/2010#updates-from", | |
"type": "application/atom+xml", | |
"href": "https://insm.cf/users/insom.atom" | |
}, | |
{ | |
"rel": "http://ostatus.org/schema/1.0/subscribe", | |
"template": "https://tiny.tilde.website/authorize_follow?acct={uri}" | |
},{ | |
"rel": "salmon", | |
"href": "https://tiny.tilde.website/api/salmon/1" | |
}, | |
{ | |
"rel": "magic-public-key", | |
"href": "data:application/magic-public-key,RSA.u-dJmtavKOuRae72q52lJuIdPfz8GYeXvkp740uRq2EnTT2qHAccDfQ6dHuwn9Ah6rPowiV8AR4xvKFMO0oO3kbRVkmDZe63oK5fufpNIp0A-D_epSL_eILYJzI_Usz6Sd-1y0BGXz0UenxCQ_UL_wPB1CMItveQ04eAhVK2gnnWRmD-gc_-NCKSZDa6Pt31RuKd-uNt2K-SU_Raq6mNnDDvq8W1As43zEk-6p73zeTCvW7U88LgcUKQ-z80DQHw2J0ifHi2a4CMu2vLKljyoG4CPOnFNcWzzVGgcOf1Nn63avbqJIaqD1oGdULHvmcxHaxQkEd_aWXb7H3UUluh8w==.AQAB" | |
} | |
] | |
} | |
return json.dumps(d), {'Content-Type': ct} | |
@app.route("/users/insom.atom") | |
def use(): | |
ct = '''application/atom+xml; charset=utf-8''' | |
xml = """<?xml version="1.0"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:mastodon="http://mastodon.social/schema/1.0"> | |
<id>https://insm.cf/users/insom.atom</id> | |
<title>Aaron Brady Bot</title> | |
<subtitle>this is not for your eyes 1</subtitle> | |
<updated>2017-04-23T06:04:44Z</updated> | |
<logo>https://insm.cf/system/accounts/avatars/000/000/001/original/f116fcdcba003480.png?1491342020</logo> | |
<author> | |
<id>https://insm.cf/users/insom</id> | |
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> | |
<uri>https://insm.cf/users/insom.atom</uri> | |
<name>insom</name> | |
<email>insom@tiny.tilde.website</email> | |
<summary>this is not for your eyes 2</summary> | |
<link rel="alternate" type="text/html" href="https://insm.cf/@insom"/> | |
<link rel="avatar" type="image/png" media:width="120" media:height="120" href="https://tiny.tilde.website/system/accounts/avatars/000/000/001/original/f116fcdcba003480.png?1491342020"/> | |
<link rel="header" type="" media:width="700" media:height="335" href="https://tiny.tilde.website/headers/original/missing.png"/> | |
<poco:preferredUsername>insom</poco:preferredUsername> | |
<poco:displayName>Aaron Brady Bot</poco:displayName> | |
<poco:note>this is not for your eyes 3</poco:note> | |
<mastodon:scope>public</mastodon:scope> | |
</author> | |
<link rel="alternate" type="text/html" href="https://insm.cf/@insom"/> | |
<link rel="self" type="application/atom+xml" href="https://insm.cf/users/insom.atom"/> | |
<link rel="next" type="application/atom+xml" href="https://insm.cf/users/insom.atom"/> | |
<link rel="hub" href="http://pubsubhubbub.superfeedr.com/"/> | |
<link rel="salmon" href="https://tiny.tilde.website/api/salmon/1"/> | |
<entry> | |
<id>tag:insm.cf,2017-04-23:objectId=3:objectType=Status</id> | |
<published>2017-04-23T06:04:30Z</published> | |
<updated>2017-04-23T06:04:30Z</updated> | |
<title>New status by insom</title> | |
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> | |
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> | |
<content type="html" xml:lang="en">~~ This is a test from an OStatus provider hacked together in Python ~~</content> | |
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> | |
<mastodon:scope>public</mastodon:scope> | |
<link rel="alternate" type="text/html" href="https://insm.cf/users/insom/updates/foo"/> | |
<link rel="self" type="application/atom+xml" href="https://insm.cf/users/insom/updates/foo.atom"/> | |
</entry></feed>""" | |
return xml, {'Content-Type': ct} | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment