diff --git a/requirements.txt b/requirements.txt index 4e1622c..81d3580 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,7 @@ alembic sqlalchemy dateparser + +TurboGears2 +kajiki +webhelpers2 diff --git a/src/www/serve.py b/src/www/serve.py new file mode 100755 index 0000000..21aa29e --- /dev/null +++ b/src/www/serve.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 + +import tg +import tg.util +import tg.configurator.components.sqlalchemy + +import sqlalchemy as sa +import sqlalchemy.orm + + +class RootController(tg.TGController): + @tg.expose('templates/index.xhtml') + def index(self, person=None): + return dict(person=person) + + +config = tg.MinimalApplicationConfigurator() +config.register(tg.configurator.components.sqlalchemy.SQLAlchemyConfigurationComponent) +config.update_blueprint({ + 'serve_static': True, + 'paths': { + 'static_files': 'static' + }, + 'root_controller': RootController(), + 'renderers': ['kajiki'], + 'helpers': 'webhelpers2', + 'use_sqlalchemy': True, + 'sqlalchemy.url': 'sqlite:///../../db/data.sqlite' +}) + + +DBSession = sqlalchemy.orm.scoped_session( + sqlalchemy.orm.sessionmaker(autoflush=True, autocommit=False) +) + +def init_model(engine): + DBSession.configure(bind=engine) + + +config.update_blueprint({ + 'model': tg.util.Bunch( + DBSession=DBSession, + init_model=init_model, + ) +}) + +application = config.make_wsgi_app() + +import wsgiref.simple_server +print ("Serving on 8080") +httpd = wsgiref.simple_server.make_server('', 8080, application) +httpd.serve_forever() diff --git a/src/www/static/.keep b/src/www/static/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/www/templates/index.xhtml b/src/www/templates/index.xhtml new file mode 100644 index 0000000..24068d4 --- /dev/null +++ b/src/www/templates/index.xhtml @@ -0,0 +1,8 @@ + + Hello + +

Hello ${person}

+
+

Hello World!

+
+