From 9bacf314d96df20758fac22a6dd3c2dc55af4e96 Mon Sep 17 00:00:00 2001 From: Sergei Miami Date: Sat, 12 Jun 2021 01:52:00 +0300 Subject: [PATCH] Hello world application with TurboGears --- README.md | 36 ++++++++++++++++++++++++++++++++++++ makefile | 7 +++++++ requirements.txt | 5 +++++ server.py | 21 +++++++++++++++++++++ setup.py | 1 + 5 files changed, 70 insertions(+) create mode 100644 makefile create mode 100644 requirements.txt create mode 100644 server.py create mode 100644 setup.py diff --git a/README.md b/README.md index 288de19..bfb3fa0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,38 @@ # python-wiki + Wiki pages in python + +## How to start + +Clone project + +```shell +git clone https://github.com/BlackCrystal/python-wiki.git +cd python-wiki +``` + +Optional, create virtual python environment and activate it + +```shell +pip install --user virtualenv +virtualenv venv +source venv/bin/activate +``` + +Install requirements + +```shell +pip install -r requirements.txt +``` + +Start webserver + +```shell +python server.py +``` + +Open webpage [http://localhost:8080/](http://localhost:8080/) and wou will see "Hello world" message. + +Now try to build something more incredible, like things we listed [here in the project](https://github.com/BlackCrystal/python-wiki/projects/1). + +GL & HF. diff --git a/makefile b/makefile new file mode 100644 index 0000000..ace5605 --- /dev/null +++ b/makefile @@ -0,0 +1,7 @@ +init: + pip install -r requirements.txt + +test: + py.test tests + +.PHONY: init test diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dcb737b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +crank==0.8.1 +MarkupSafe==2.0.1 +repoze.lru==0.7 +TurboGears2==2.4.3 +WebOb==1.8.7 \ No newline at end of file diff --git a/server.py b/server.py new file mode 100644 index 0000000..0cfbddf --- /dev/null +++ b/server.py @@ -0,0 +1,21 @@ +from tg import expose, TGController + +class RootController(TGController): + @expose() + def index(self): + return 'Hello World' + +from tg import MinimalApplicationConfigurator + +config = MinimalApplicationConfigurator() +config.update_blueprint({ + 'root_controller': RootController() +}) + +application = config.make_wsgi_app() + +from wsgiref.simple_server import make_server + +print("Serving on port 8080...") +httpd = make_server('', 8080, application) +httpd.serve_forever() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4265cc3 --- /dev/null +++ b/setup.py @@ -0,0 +1 @@ +#!/usr/bin/env python