aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-03-26 22:15:05 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-03-26 22:15:05 +0100
commitb7c6edf9d519ee1f3516d6e4cf60ca25269a74d0 (patch)
tree0fe64999e0b46bc38bfe29fa434532dc78ff7817
parent253235e8c583e383695874607bf727430d316520 (diff)
Tornado HelloWorld
-rw-r--r--.gitignore4
-rw-r--r--README.rst11
-rwxr-xr-xpyactivitypubd11
-rw-r--r--pyapd/app.py14
-rwxr-xr-xrun_tests4
-rw-r--r--tests/test_app.py12
6 files changed, 56 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e933fda
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.coverage
+*.pyc
+
+.*.sw?
diff --git a/README.rst b/README.rst
index 81d9efd..b9fd91b 100644
--- a/README.rst
+++ b/README.rst
@@ -8,6 +8,17 @@ with clients through the ActivityPub c2s protocol.
.. _ActivityPub: https://www.w3.org/TR/activitypub/
+Installation
+============
+
+Dependencies
+------------
+
+PyAPD requires the following dependencies and targets their versions as
+available in Debian buster.
+
+* `Tornado <https://www.tornadoweb.org>`
+
License
=======
diff --git a/pyactivitypubd b/pyactivitypubd
new file mode 100755
index 0000000..d89dd96
--- /dev/null
+++ b/pyactivitypubd
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+
+import tornado.ioloop
+
+from pyapd import app
+
+
+if __name__ == "__main__":
+ apd = app.App()
+ apd.listen(8888)
+ tornado.ioloop.IOLoop.current().start()
diff --git a/pyapd/app.py b/pyapd/app.py
new file mode 100644
index 0000000..b470688
--- /dev/null
+++ b/pyapd/app.py
@@ -0,0 +1,14 @@
+import tornado.web
+
+
+class RootHandler(tornado.web.RequestHandler):
+ def get(self):
+ self.write("Hello World")
+
+
+class App(tornado.web.Application):
+ def __init__(self, *args, **kw):
+ urls = [
+ (r'/', RootHandler),
+ ]
+ super().__init__(urls, *args, **kw)
diff --git a/run_tests b/run_tests
new file mode 100755
index 0000000..b609f1f
--- /dev/null
+++ b/run_tests
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+nose2-3 --with-coverage --coverage-report=term
+flake8 .
diff --git a/tests/test_app.py b/tests/test_app.py
new file mode 100644
index 0000000..a2ff27a
--- /dev/null
+++ b/tests/test_app.py
@@ -0,0 +1,12 @@
+from tornado.testing import AsyncHTTPTestCase
+
+from pyapd import app
+
+
+class TestApp(AsyncHTTPTestCase):
+ def get_app(self, *args, **kw):
+ return app.App()
+
+ def test_root(self):
+ res = self.fetch('/')
+ self.assertEqual(res.code, 200)