parthpethia commited on
Commit
4355808
·
1 Parent(s): 6031a66

Fix template loading - update Dockerfile and app.py

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. app.py +25 -3
Dockerfile CHANGED
@@ -8,6 +8,7 @@ RUN pip install --no-cache-dir -r requirements.txt
8
 
9
  # Copy application code
10
  COPY environment/ ./environment/
 
11
  COPY app.py .
12
  COPY openenv.yaml .
13
  COPY inference.py .
 
8
 
9
  # Copy application code
10
  COPY environment/ ./environment/
11
+ COPY templates/ ./templates/
12
  COPY app.py .
13
  COPY openenv.yaml .
14
  COPY inference.py .
app.py CHANGED
@@ -1,13 +1,14 @@
1
  """Flask REST API server for Email Triage OpenEnv."""
2
 
3
  import os
 
4
 
5
- from flask import Flask, request, jsonify, render_template
6
 
7
  from environment.env import EmailTriageEnv
8
  from environment.types import Action
9
 
10
- app = Flask(__name__)
11
 
12
  # Global environment instances (one per task)
13
  environments = {}
@@ -21,7 +22,28 @@ def get_env(task_name: str = "spam_detection") -> EmailTriageEnv:
21
  @app.route("/", methods=["GET"])
22
  def index():
23
  """Root endpoint - Interactive dashboard"""
24
- return render_template("index.html")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  @app.route("/health", methods=["GET"])
27
  def health():
 
1
  """Flask REST API server for Email Triage OpenEnv."""
2
 
3
  import os
4
+ from pathlib import Path
5
 
6
+ from flask import Flask, request, jsonify, render_template, send_file
7
 
8
  from environment.env import EmailTriageEnv
9
  from environment.types import Action
10
 
11
+ app = Flask(__name__, template_folder=os.path.join(os.path.dirname(__file__), 'templates'))
12
 
13
  # Global environment instances (one per task)
14
  environments = {}
 
22
  @app.route("/", methods=["GET"])
23
  def index():
24
  """Root endpoint - Interactive dashboard"""
25
+ try:
26
+ return render_template("index.html")
27
+ except Exception:
28
+ # Fallback: read HTML file directly
29
+ html_path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html')
30
+ if os.path.exists(html_path):
31
+ with open(html_path, 'r', encoding='utf-8') as f:
32
+ return f.read()
33
+ return jsonify({
34
+ "status": "ok",
35
+ "message": "Email Triage OpenEnv API",
36
+ "version": "1.0.0",
37
+ "note": "Dashboard not available. Use API endpoints directly.",
38
+ "endpoints": {
39
+ "health": "GET /health",
40
+ "tasks": "GET /tasks",
41
+ "reset": "POST /reset?task=spam_detection",
42
+ "step": "POST /step?task=spam_detection",
43
+ "state": "GET /state?task=spam_detection",
44
+ "state-describe": "GET /state-describe?task=spam_detection"
45
+ }
46
+ }), 200
47
 
48
  @app.route("/health", methods=["GET"])
49
  def health():