import os
import random
import configparser
import requests
from flask import Flask, render_template_string, jsonify, send_from_directory
app = Flask(__name__)
OLLAMA_HOST = os.environ.get("OLLAMA_HOST", "http://harbor.freshbrewed.science:11444")
OLLAMA_MODEL = os.environ.get("OLLAMA_MODEL", "gemma4:e4b")
PROMPT = os.environ.get("JOKE_PROMPT", "tell me a dad joke about programming")
PORT = int(os.environ.get("PORT", "80"))
PRESET_JOKES = [
"What do you call parenting with a software engineer? Pair programming (or O-pair programming).",
"My kids were rolling on the floor and screaming. My wife asked what was happening, and I told her it was a version conflict.",
"When I wrote this code, only God and I knew how it worked. Now, only God knows.",
"A programmer is sent to the store by his wife: “Get a gallon of milk, and if they have eggs, get a dozen.” The programmer returns home with 13 gallons of milk and says, “They had eggs”.",
"Where do coder dads store all their projects? In a dad-abase.",
"Why don't programmers like going outside into nature? Too many bugs.",
"Why did the programmer die taking a shower? The shampoo bottle instructions said: Lather. Rinse. Repeat."
]
def get_app_version():
config = configparser.ConfigParser()
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.ini")
if os.path.exists(version_file):
try:
config.read(version_file)
return config.get("metadata", "version", fallback="unknown")
except Exception:
return "unknown"
return "unknown"
HTML_TEMPLATE = """