EMAIL_HOST = "smtp.beget.com"
EMAIL_HOST_USER = "info@site.ru"
EMAIL_HOST_PASSWORD = "&*R5mVWt"
EMAIL_PORT = 465
EMAIL_USE_SSL = True
SERVER_EMAIL = "info@site.ru"
DEFAULT_FROM_EMAIL = "info@site.ru"
# run_rq.py
import sys
from rq import Connection
from worker import CustomWorker
# Preload libraries
from pydarknet import Detector
detector = Detector(bytes('cfg/yolov3.cfg', encoding='utf-8'),
bytes('weights/yolov3.weights', encoding='utf-8'),
0,
bytes('cfg/coco.data',encoding='utf-8'))
# Provide queue names to listen to as arguments to this script,
# similar to rq worker
with Connection():
qs = sys.argv[1:] or ['default']
w = CustomWorker(qs)
w.detector = detector
w.work()
# worker.py
from rq.worker import (DEFAULT_JOB_MONITORING_INTERVAL, DEFAULT_RESULT_TTL,
DEFAULT_WORKER_TTL, Worker)
import settings
class CustomWorker(Worker):
def __init__(self, queues, name=None, default_result_ttl=DEFAULT_RESULT_TTL,
connection=None, exc_handler=None, exception_handlers=None,
default_worker_ttl=DEFAULT_WORKER_TTL, job_class=None,
queue_class=None,
job_monitoring_interval=DEFAULT_JOB_MONITORING_INTERVAL):
super(CustomWorker, self).__init__(queues, name, default_result_ttl,
connection, exc_handler, exception_handlers, default_worker_ttl,
job_class, queue_class,job_monitoring_interval)
self.detector = None
def execute_job(self, job, queue):
if not self.detector is None:
job.detector = self.detector
super(CustomWorker, self).execute_job(job, queue)
# tasks.py
from rq import get_current_job
import settings
def send():
job = get_current_job()
if not job.detector is None:
# do more work
from notification.connection import ClientConnection
class BroadcastHandler(tornado.web.RequestHandler):
def post(self):
message = self.get_argument('message', default="")
for client in ClientConnection.clients:
data = json.loads(message)
if data['dev'] in client.devices:
client.send(message)
self.write(str(ClientConnection.clients))
location / {
#
if ($request_method = 'PUT') {
more_set_headers "Access-Control-Allow-Origin: http://localhost";
more_set_headers "Access-Control-Allow-Credentials: true";
more_set_headers "Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Pragma,Authorization";
}
#
}
'stores': Store.objects.all()
{% if stores %}
<div class="footer-col-2">
<div class="col-name">Наши магазины</div>
<ul class='stores'>
{% for store in stores_queryset %}
<li>
<span>{{ store.name }} - {{ store.address }}</span>
<ul>
{% for phone in store.phones_set %}
<li>{{ phone.name }}: {{ phone.phone }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% endif %}