mirror of
https://github.com/thecyberlearn/chat-backend.git
synced 2026-08-18 23:32:53 +00:00
Features: - Django REST API backend - Multi-strategy web scraping system (Beautiful Soup, Playwright, Firecrawl) - Anti-detection features (proxy rotation, user-agent rotation) - Data export functionality (JSON, CSV, TXT) - Business and CrawledPage models - Enhanced crawling service with fallback mechanisms 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
672 B
Python
27 lines
672 B
Python
"""
|
|
Wrapper for loading templates from a plain Python dict.
|
|
"""
|
|
|
|
from django.template import Origin, TemplateDoesNotExist
|
|
|
|
from .base import Loader as BaseLoader
|
|
|
|
|
|
class Loader(BaseLoader):
|
|
def __init__(self, engine, templates_dict):
|
|
self.templates_dict = templates_dict
|
|
super().__init__(engine)
|
|
|
|
def get_contents(self, origin):
|
|
try:
|
|
return self.templates_dict[origin.name]
|
|
except KeyError:
|
|
raise TemplateDoesNotExist(origin)
|
|
|
|
def get_template_sources(self, template_name):
|
|
yield Origin(
|
|
name=template_name,
|
|
template_name=template_name,
|
|
loader=self,
|
|
)
|