Skip to content

Instantly share code, notes, and snippets.

View mosi-kha's full-sized avatar
😜

mostafa khaki mosi-kha

😜
View GitHub Profile
@mosi-kha
mosi-kha / django_q_exporter.py
Last active October 14, 2024 17:43
prometheus exporter for Django Q
from datetime import timedelta
from django.conf import settings
from django.http import HttpResponse, HttpResponseNotFound
from django.utils import timezone
from django_q import models
from django_q.monitor import Stat
from django_redis import get_redis_connection
from prometheus_client import Gauge, generate_latest
@mosi-kha
mosi-kha / object_id_field.py
Created July 11, 2021 07:04
MongoDB Object Id field for DRF serializer
from bson import ObjectId
from bson.errors import InvalidId
from django.utils.encoding import smart_str
from rest_framework import serializers
class ObjectIdField(serializers.Field):
"""Field for ObjectId values"""
def to_internal_value(self, value):
@mosi-kha
mosi-kha / version_api_falcon.md
Last active July 11, 2021 07:05
versioning API in falcon framework v2

1

first in your route, use this base url : /api/{version}

2

then create this file: decorator.py

import falcon

class UriVersion:
 def __init__(self, version: list):