Example #1
0
    def __init__(self, **kwargs):
        self.server = Webserver()
        super().__init__(**kwargs)

        # add middlewares and other apps here...
        self.server.add_app(StaticApp(prefix='static', path='static'))
        self.server.add_app(self)
Example #2
0
    def __init__(self, **kwargs):
        self.server = Webserver()
        super().__init__(**kwargs)

        static_prefix = kwargs.get('static_prefix', 'static')
        static_path = kwargs.get('static_path', 'static')

        # add middlewares and other apps here...
        self.server.add_app(StaticApp(prefix=static_prefix, path=static_path))
        self.server.add_app(self)
Example #3
0
__author__ = 'Tobias Thelen'

from server import webserver
from server.apps.info import InfoApp
from server.apps.static import StaticApp


class WelcomeApp(webserver.App):
    """Says hello."""

    def register_routes(self):
        self.add_route("", self.welcome)

    def welcome(self, request, response, pathmatch):
        """Redirects to /static/welcome.html."""
        response.send_redirect('/static/welcome.html')

    def __str__(self):
        return "WelcomeApp"


if __name__ == '__main__':
    s = webserver.Webserver()
    s.add_app(WelcomeApp())
    s.add_app(InfoApp(prefix='info'))
    s.add_app(StaticApp(prefix='static', path='static'))
    s.serve()
Example #4
0
            else:
                return response.send_template(
                    'login.tmpl',
                    {'message': 'Wrong username or password. Try again.'})
        # send login form
        return response.send_template(
            'login.tmpl', {'user': server.usermodel.AnonymousUser()})


if __name__ == '__main__':

    db = sqlite.connect('minitwitter.sqlite')  # use sqlite db
    db.row_factory = sqlite.Row  # fetch rows as Row objects (easier to access)

    s = Webserver()
    s.set_templating("jinja2")
    s.set_templating_path("templates.jinja2")

    s.add_middleware(SessionMiddleware())
    s.add_middleware(CsrfMiddleware())

    s.add_app(UsermanagementApp(db_connection=db)
              )  # Sub-App: create, change, delete users. (code in server/apps)
    s.add_app(StaticApp(prefix='static',
                        path='static'))  # deliver static files

    s.add_app(MiniTwitterApp('data', db_connection=db))  # the twitter app

    log(0, "Server running.")
    s.serve()
Example #5
0
__author__ = 'Tobias Thelen'

from server import webserver
from server.apps.static import StaticApp

import os

if __name__ == '__main__':
    s = webserver.Webserver()
    s.add_app(StaticApp(path='static'))
    s.serve()
Example #6
0
class FortyTwoApp(App):
    """A very wise simple App."""
    def register_routes(self):
        self.add_route("", self.theanswer)

    def theanswer(self, request, response, pathmatch):
        response.send(200, body="<html><body><h1>42</h1></body></html>")


if __name__ == '__main__':
    s = Webserver()

    # Static app for static folder
    static = StaticApp(prefix='static',
                       path='static',
                       name='Statischer Dateibereich')
    static.default_entry = "/static/"
    s.add_app(static)

    # Flappy Bird clone via StaticApp
    floppy = StaticApp(prefix='floppy',
                       path='3rdparty/floppybird',
                       name='Floppy Bird (js game)')
    floppy.default_entry = "/floppy/index.html"
    s.add_app(floppy)

    # 2048 game via StaticApp
    game2048 = StaticApp(prefix='2048',
                         path='3rdparty/2048',
                         name='2048 (js game)')
Example #7
0
from server import webserver
from server.apps.static import StaticApp
from server.apps.index import IndexApp

if __name__ == '__main__':
    server = webserver.Webserver(port=8080)
    server.add_app(
        StaticApp(prefix='static',
                  name="StaticApp",
                  path='static',
                  einstiegsroute='/static/'))
    #server.add_app(StaticApp(prefix='Dynamic', name="DynamicApp", path='Dynamic', einstiegsroute='/Dynamic/'))
    #server.add_app(StaticApp(prefix='Test', name="TestApp", path='Test', einstiegsroute='/Test/'))
    #server.add_app(StaticApp(prefix='World', name="WorldApp", path='World', einstiegsroute='/World/'))
    server.add_app(
        IndexApp(servername="Toller Server",
                 name="IndexApp",
                 einstiegsroute=''))
    server.serve()