django-tsp is a django travel salesman problem.
Project description
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
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
django_tsp-3.14.8.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for django_tsp-3.14.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fb3880aa0169d9cbfd1ed35f219a4109e6b67307dde9260621e90ee625ef04c |
|
MD5 | 0fc3a8366bda3049b8263fd46068c402 |
|
BLAKE2b-256 | 63c580738d6f1dfe9da0bc86b805a446aa979bc6a138ced933127dda4c78a4be |