import pandas as pd import matplotlib.pyplot as plt from flask import Blueprint, render_template_string, request, jsonify, Response, send_from_directory import os import json # Create Blueprint xrd_plot_bp = Blueprint('xrd_plot', __name__, url_prefix='/xrd') XRD_DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Data', 'XRD') @xrd_plot_bp.route('/data/metadata.json') def xrd_metadata(): """Serve the locally bundled XRD metadata.""" response = send_from_directory( XRD_DATA_DIR, 'metadata.json.gz', mimetype='application/json', conditional=True, ) response.headers['Content-Encoding'] = 'gzip' response.headers['Vary'] = 'Accept-Encoding' return response @xrd_plot_bp.route('/data/.json') def xrd_dataset(dataset): """Stream a locally bundled XRD dataset on demand.""" response = send_from_directory( os.path.join(XRD_DATA_DIR, 'datasets'), f'{dataset}.json.gz', mimetype='application/json', conditional=True, ) response.headers['Content-Encoding'] = 'gzip' response.headers['Vary'] = 'Accept-Encoding' return response @xrd_plot_bp.route('/') def xrd_plot_main(): """Main XRD plot page""" # Create the HTML template exactly matching the original XRD dashboard html_template = r''' OCx25 XRD Analysis Dashboard ← Back to Dashboard

OCx25 XRD Analysis Dashboard

Table overview of all XRD fitting solutions

# RWP Score # Phases Phase Names Weights Visual Action
Select a dataset and sample to view iterations
''' return html_template