django_tsp
django_tsp is a wrapper build on top of the tsp_wrapper
- Provide apis for calling the tsp_wrapper
- Provide django commands for tsp_wrapper
- Provide websocket template for tsp sloutions
Installation
pip install django-tsp
Getting started
- Add django_tsp to your install apps
INSTALLED_APPS = [
'daphne',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django_tsp', # <--- here we added our package
]
- fill up the require variables in settings.py
TSP_HOOK_URL="http://django:8000/api/tsp/hook/" # your webhook link
TSP_BROKER_URL = "amqp://guest:guest@rabbitmq:5672/"
- install django_channels and use following view in your routing
from django_tsp.routing import ws_urlpatterns
application = ProtocolTypeRouter({
"http": django_asgi_app,
"websocket": AuthMiddlewareStack(URLRouter(ws_urlpatterns))
})
- use add following apis to your urls.py (needs drf and drf_docs)
from django_tsp.apis import WebhookApi, SolverApi
urlpatterns = [
path('tsp/', include(([
path('solver/', SolverApi.as_view(), name="solver"),
path('hook/', WebhookApi.as_view(), name="hook"),
], "tsp")), ),
]
- for the template websocket add following views inside of your urls.py
from django_tsp.views import index
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
urlpatterns = [
path('', index, name="index"), # the improtant template one
path("schema/", SpectacularAPIView.as_view(api_version="v1"), name="schema"),
path("doc/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui"),
path("redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
]
Usage
- for running the bridge
python manage.py bridge
- for running the reciver
python manage.py reciver
Metadata
Release files for django-tsp 3.14.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_tsp-3.14.8.tar.gz | 10.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_tsp-3.14.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.0 kB
Release files / django_tsp-3.14.8.tar.gz
| Download URL | django_tsp-3.14.8.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c792a6538c0441acea59b0a869d330e69e3150f74c6d037e37c7db5034f3d2b5
|
|
BLAKE2b-256 checksum How to use checksums |
d12fbef8af40d1a417d782055f9a8213e3593256599c589345b87d1e41423254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|
Release files / django_tsp-3.14.8-py3-none-any.whl
| Download URL | django_tsp-3.14.8-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fb3880aa0169d9cbfd1ed35f219a4109e6b67307dde9260621e90ee625ef04c
|
|
BLAKE2b-256 checksum How to use checksums |
63c580738d6f1dfe9da0bc86b805a446aa979bc6a138ced933127dda4c78a4be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|