MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / two_factor

Function two_factor

Scripts/ButSystem.py:11233–11296  ·  view source on GitHub ↗

two_factor. Internal helper function. This docstring was added automatically to improve maintainability. Returns: Varies.

()

Source from the content-addressed store, hash-verified

11231 if len(balanced) >= 800:
11232 break
11233 return balanced
11234
11235def get_news_items(lang: str, force: bool = False) -> List[Dict[str, str]]:
11236 """Return cached news items (per-language)."""
11237 lang = "el" if lang == "el" else "en"
11238 now = time.time()
11239 with _NEWS_LOCK:
11240 ts = float(_NEWS_CACHE["ts"].get(lang, 0.0) or 0.0)
11241 cached = list(_NEWS_CACHE["items"].get(lang, []) or [])
11242 if cached and not force and (now - ts) < _NEWS_TTL:
11243 return cached
11244
11245 # Refresh outside lock (avoid blocking other requests)
11246 try:
11247 fresh = _fetch_news_uncached(lang)
11248 except Exception:
11249 fresh = []
11250
11251 with _NEWS_LOCK:
11252 _NEWS_CACHE["ts"][lang] = time.time()
11253 _NEWS_CACHE["items"][lang] = fresh
11254
11255 return list(fresh)
11256
11257@app.route("/news")
11258@login_required
11259def news():
11260 """News page: worldwide headlines by topic, in EN/EL based on the UI language."""
11261 lang = get_lang()
11262 # UI topics list with labels in the current language
11263 topics = [{"key": "all", "label": ("All" if lang == "en" else "Όλα")}]
11264 for key, labels, _q in NEWS_TOPICS:
11265 topics.append({"key": key, "label": labels.get(lang, labels["en"])})
11266 return render_template("news.html", title=_("News"), topics=topics)
11267
11268@app.route("/api/news")
11269@login_required
11270def api_news():
11271 """Return worldwide headlines (RSS aggregated) in the current language."""
11272 lang = (request.args.get("lang") or get_lang() or "en").strip().lower()
11273 if lang not in ("en", "el"):
11274 lang = get_lang()
11275 force = (request.args.get("force") == "1")
11276 items = []
11277 try:
11278 items = get_news_items(lang, force=force)
11279 except Exception:
11280 items = []
11281 return jsonify({"ok": True, "lang": lang, "items": items})
11282
11283
11284@app.route("/login", methods=["GET", "POST"])
11285def login():
11286 """login.
11287
11288Route handler or application helper.
11289
11290This docstring was expanded to make future maintenance easier.

Callers

nothing calls this directly

Calls 10

_client_ipFunction · 0.70
_too_many_attemptsFunction · 0.70
db_connectFunction · 0.70
verify_security_answersFunction · 0.70
_mark_failFunction · 0.70
current_scopeFunction · 0.70
user_is_adminFunction · 0.70
scope_capacity_okFunction · 0.70
_clear_failFunction · 0.70
_complete_login_sessionFunction · 0.70

Tested by

no test coverage detected