From b7c6edf9d519ee1f3516d6e4cf60ca25269a74d0 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Tue, 26 Mar 2019 22:15:05 +0100 Subject: Tornado HelloWorld --- .gitignore | 4 ++++ README.rst | 11 +++++++++++ pyactivitypubd | 11 +++++++++++ pyapd/app.py | 14 ++++++++++++++ run_tests | 4 ++++ tests/test_app.py | 12 ++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100755 pyactivitypubd create mode 100644 pyapd/app.py create mode 100755 run_tests create mode 100644 tests/test_app.py 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 ` + 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) -- cgit v1.2.3