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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tsp-3.14.8.tar.gz.
File metadata
- Download URL: django_tsp-3.14.8.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c792a6538c0441acea59b0a869d330e69e3150f74c6d037e37c7db5034f3d2b5
|
|
| MD5 |
2a80c8c64a1bfe76d60296991e7d2ea1
|
|
| BLAKE2b-256 |
d12fbef8af40d1a417d782055f9a8213e3593256599c589345b87d1e41423254
|
File details
Details for the file django_tsp-3.14.8-py3-none-any.whl.
File metadata
- Download URL: django_tsp-3.14.8-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb3880aa0169d9cbfd1ed35f219a4109e6b67307dde9260621e90ee625ef04c
|
|
| MD5 |
0fc3a8366bda3049b8263fd46068c402
|
|
| BLAKE2b-256 |
63c580738d6f1dfe9da0bc86b805a446aa979bc6a138ced933127dda4c78a4be
|