Example #1
0
def run_server(port):

    # Mount the application
    from kolibri.deployment.default.wsgi import application
    cherrypy.tree.graft(application, "/")

    cherrypy.config.update({"environment": "production"})

    serve_static_dir(settings.STATIC_ROOT, settings.STATIC_URL)
    serve_static_dir(settings.CONTENT_DATABASE_DIR,
                     paths.get_content_database_url("/"))
    serve_static_dir(settings.CONTENT_STORAGE_DIR,
                     paths.get_content_storage_url("/"))

    # Unsubscribe the default server
    cherrypy.server.unsubscribe()

    # Instantiate a new server object
    server = cherrypy._cpserver.Server()

    # Configure the server
    server.socket_host = "0.0.0.0"
    server.socket_port = port
    server.thread_pool = 30

    # Subscribe this server
    server.subscribe()

    # Start the server engine (Option 1 *and* 2)
    cherrypy.engine.start()
    cherrypy.engine.block()
Example #2
0
def run_server():

    # Mount the application
    cherrypy.tree.graft(application, "/")

    serve_static_dir(settings.STATIC_ROOT, settings.STATIC_URL)
    serve_static_dir(settings.CONTENT_DATABASE_DIR, paths.get_content_database_url("/"))
    serve_static_dir(settings.CONTENT_STORAGE_DIR, paths.get_content_storage_url("/"))

    # Unsubscribe the default server
    cherrypy.server.unsubscribe()

    cherrypy.config.update({'server.socket_host': "0.0.0.0",
                            'server.socket_port': 8080,
                            'server.thread_pool': 30,
                            'log.screen': True})

    # Instantiate a new server object
    server = cherrypy._cpserver.Server()

    # Subscribe this server
    server.subscribe()

    # Start the server engine (Option 1 *and* 2)

    cherrypy.engine.start()
    cherrypy.engine.block()
Example #3
0
def run_server(port):

    # Mount the application
    from kolibri.deployment.default.wsgi import application
    cherrypy.tree.graft(application, "/")

    serve_static_dir(settings.STATIC_ROOT, settings.STATIC_URL)
    serve_static_dir(
        settings.CONTENT_DATABASE_DIR, paths.get_content_database_url("/")
    )
    serve_static_dir(
        settings.CONTENT_STORAGE_DIR, paths.get_content_storage_url("/")
    )

    # Unsubscribe the default server
    cherrypy.server.unsubscribe()

    # Instantiate a new server object
    server = cherrypy._cpserver.Server()

    # Configure the server
    server.socket_host = "0.0.0.0"
    server.socket_port = port
    server.thread_pool = 30

    # Subscribe this server
    server.subscribe()

    # Start the server engine (Option 1 *and* 2)
    cherrypy.engine.start()
    cherrypy.engine.block()
Example #4
0
def run_server():

    # Mount the application
    cherrypy.tree.graft(application, "/")

    serve_static_dir(settings.STATIC_ROOT, settings.STATIC_URL)
    serve_static_dir(settings.CONTENT_DATABASE_DIR, paths.get_content_database_url("/"))
    serve_static_dir(settings.CONTENT_STORAGE_DIR, paths.get_content_storage_url("/"))

    # Unsubscribe the default server
    cherrypy.server.unsubscribe()

    cherrypy.config.update({'server.socket_host': "0.0.0.0",
                            'server.socket_port': 8080,
                            'server.thread_pool': 30,
                            'log.screen': True})

    # Instantiate a new server object
    server = cherrypy._cpserver.Server()

    # Subscribe this server
    server.subscribe()

    # Start the server engine (Option 1 *and* 2)

    cherrypy.engine.start()
    cherrypy.engine.block()
Example #5
0

Defining URLs for plugins
-------------------------

Plugin classes can define url modules, and they will automatically be included.

Place a url.py and have your plugin's definition class's ``url_module`` method
return the module.
"""
from __future__ import absolute_import, print_function, unicode_literals

from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from kolibri.content.utils import paths
from kolibri.plugins.registry import get_urls as plugin_urls

from .views import set_language

app_name = 'kolibri'

urlpatterns = plugin_urls()

urlpatterns += static(paths.get_content_storage_url("/"),
                      document_root=settings.CONTENT_STORAGE_DIR)
urlpatterns += static(paths.get_content_database_url("/"),
                      document_root=settings.CONTENT_DATABASE_DIR)

urlpatterns += [url(r'^i18n/setlang/$', set_language, name='set_language')]
    <!-- A built-in kolibri URL -->
    {% url 'kolibri:url_name' %}

    <!-- A plugin URL -->
    {% url 'kolibri:pluginnamespace:url_name' %}


Defining URLs for plugins
-------------------------

Plugin classes can define url modules, and they will automatically be included.

Place a url.py and have your plugin's definition class's ``url_module`` method
return the module.
"""
from __future__ import absolute_import, print_function, unicode_literals

from django.conf import settings
from django.conf.urls.static import static
from kolibri.content.utils import paths
from kolibri.plugins.registry import get_urls as plugin_urls

app_name = 'kolibri'


urlpatterns = plugin_urls()

urlpatterns += static(paths.get_content_storage_url("/"), document_root=settings.CONTENT_STORAGE_DIR)
urlpatterns += static(paths.get_content_database_url("/"), document_root=settings.CONTENT_DATABASE_DIR)