Skip to main content

valar for morghulis

Project description

valar for morghulis

settings

from pathlib import Path

""" Compulsory settings """
DEBUG = True
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_APP = str(BASE_DIR.name)
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


""" DataSource """

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

MONGO_SETTINGS = {
    'host': '47.98.192.120',
    'port': 27017,
    "username": "admin",
    "password": '19870120'
}

MINIO_SETTINGS = {
    'endpoint': '10.134.10.92:9000',
    'access_key': 'admin',
    "secret_key": "19870120",
    'secure': False
}

""" Minimized compulsory settings """

INSTALLED_APPS = [
    'django.contrib.sessions',
    "corsheaders",
    'channels',
    'valar.data'
]

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'valar.Middleware'
]

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels.layers.InMemoryChannelLayer"
    }
}

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
ROOT_URLCONF = "%s.urls" % BASE_APP
ASGI_APPLICATION = "%s.asgi.application" % BASE_APP
VALAR_CHANNEL_HANDLER_MAPPING = "%s.urls.channel_handler_mapping" % BASE_APP


""" Optional settings """
# ALLOWED_HOSTS = ['*']
# LANGUAGE_CODE = 'en-us'
# TIME_ZONE = 'Asia/Shanghai'
# USE_I18N = True
# USE_TZ = False
# SESSION_SAVE_EVERY_REQUEST = True
# SESSION_COOKIE_AGE = 60 * 60
# FILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 100
# DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 100

root urls

from django.urls import path, include

from valar.channels import ValarSocketSender
from valar.channels.views import handel_channel

urlpatterns = [
    path('socket/<str:handler>', handel_channel),
    path('data/', include('valar.data.urls')),
]


channel_handler_mapping = {
    # 'test': test_handler
}

# async def test_handler(data, sender: ValarSocketSender):
#     # print(data, sender.handler, sender.client, sender.uid)
#     await sender.to_users({'user': 15}, 15)
#     for i in range(3):
#         await sender.to_clients({'h': i},sender.client)

asgi

from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import re_path

from valar.channels import ValarConsumer

application = ProtocolTypeRouter({
    'http': get_asgi_application(),
     'websocket': URLRouter([
        re_path(r'(?P<client>\w+)/$', ValarConsumer.as_asgi()),
    ])
})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

valar-1.0.23.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

valar-1.0.23-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file valar-1.0.23.tar.gz.

File metadata

  • Download URL: valar-1.0.23.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for valar-1.0.23.tar.gz
Algorithm Hash digest
SHA256 b8d60dfcc2000a8582ee1f7f0d33c0f8b27a1a6d04ef229015908630f7a4a410
MD5 224f869722bb0e0986952cfe4ebe76cf
BLAKE2b-256 0aaceeac50f5dca2ff6547d2d8dfdf693e09b6a38d5cf97292a3e60f5074af18

See more details on using hashes here.

File details

Details for the file valar-1.0.23-py3-none-any.whl.

File metadata

  • Download URL: valar-1.0.23-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for valar-1.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 a3842649b1243582410dec460ce271d8fb641ee2707b334ab4cdf61b3c6444ea
MD5 94d298b5c26d2d2de6515b3f63742baa
BLAKE2b-256 b6ee4f0e0437e987823d0166944df3bb60f2615ae3b3ef281611a7ee338d73be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page