<commit_before>import os, sys, inspect

# ensure pyeq2 can be imported
if -1 != sys.path[0].find('pyeq2-read-only'):raise Exception('Please rename SVN checkout directory from "pyeq2-read-only" to "pyeq2"')
exampleFileDirectory = sys.path[0][:sys.path[0].rfind(os.sep)]
pyeq2ImportDirectory =  os.path.join(os.path.join(exampleFileDirectory, '..'), '..')
if pyeq2ImportDirectory not in sys.path:
    sys.path.append(pyeq2ImportDirectory)
    
import pyeq2, GraphUtils, TextUtils
from flask import Flask
from flask import request


# override Flask's default file cache for the files we generate
class MyFlask(Flask):
    def get_send_file_max_age(self, name):
        if name.lower().endswith('.png'):
            return 0.000001
        if name.lower().endswith('.txt'):
            return 0.000001
        return flask.Flask.get_send_file_max_age(self, name)


app = MyFlask(__name__)
app.debug = True # only for development, never for production



exampleData_2D = '''
  X        Y
5.357    10.376
5.457    10.489
5.936    11.049
6.161    11.327 ending text is ignored
6.697    12.054
8.442    14.744
9.769    17.068
9.861    17.104
'''

exampleData_3D = '''
    X      Y       Z
  3.017  2.175   0.0320
  2.822  2.624   0.0629
  1.784  3.144   6.570
  1.712  3.153   6.721
  2.972  2.106   0.0313
  2.719  2.542   0.0643
  2.0 2.6 4.0  ending text is ignored
  1.479  2.957   6.583
  1.387  2.963   6.744
  2.843  1.984   0.0315
  2.485  2.320   0.0639
  0.742  2.568   6.581
  0.607  2.571   6.753
'''

@app.route('/')
def test_curve_fiting_and_plotting():

    htmlToReturn = '' # build this as we progress through the example
    
    # First a simple form for a 2D fitter
    htmlToReturn_2Dform = '' # build this string as we progress
    
    # this HTML table gives an visual outline around the form
    htmlToReturn_2Dform += '<table border=1 cellpadding=20>\n'

    htmlToReturn_2Dform += '<tr><td><b>Example 2D f(x) Web Fitter</b></td></tr>\n'

    # HTML form for the 2D fitter
    htmlToReturn_2Dform += '<tr><td>\n'
    htmlToReturn_2Dform += '<form action="/simplefitter_2D" method="post" target=_blank>\n'

    # text data entry<commit_msg>Removed unused line of code from Web example<commit_after>import os, sys, inspect

# ensure pyeq2 can be imported
if -1 != sys.path[0].find('pyeq2-read-only'):raise Exception('Please rename SVN checkout directory from "pyeq2-read-only" to "pyeq2"')
exampleFileDirectory = sys.path[0][:sys.path[0].rfind(os.sep)]
pyeq2ImportDirectory =  os.path.join(os.path.join(exampleFileDirectory, '..'), '..')
if pyeq2ImportDirectory not in sys.path:
    sys.path.append(pyeq2ImportDirectory)
    
import pyeq2, GraphUtils, TextUtils
from flask import Flask
from flask import request


# override Flask's default file cache for the files we generate
class MyFlask(Flask):
    def get_send_file_max_age(self, name):
        if name.lower().endswith('.png'):
            return 0.000001
        if name.lower().endswith('.txt'):
            return 0.000001
        return flask.Flask.get_send_file_max_age(self, name)


app = MyFlask(__name__)
app.debug = True # only for development, never for production



exampleData_2D = '''
  X        Y
5.357    10.376
5.457    10.489
5.936    11.049
6.161    11.327 ending text is ignored
6.697    12.054
8.442    14.744
9.769    17.068
9.861    17.104
'''

exampleData_3D = '''
    X      Y       Z
  3.017  2.175   0.0320
  2.822  2.624   0.0629
  1.784  3.144   6.570
  1.712  3.153   6.721
  2.972  2.106   0.0313
  2.719  2.542   0.0643
  2.0 2.6 4.0  ending text is ignored
  1.479  2.957   6.583
  1.387  2.963   6.744
  2.843  1.984   0.0315
  2.485  2.320   0.0639
  0.742  2.568   6.581
  0.607  2.571   6.753
'''

@app.route('/')
def test_curve_fiting_and_plotting():

    # First a simple form for a 2D fitter
    htmlToReturn_2Dform = '' # build this string as we progress
    
    # this HTML table gives an visual outline around the form
    htmlToReturn_2Dform += '<table border=1 cellpadding=20>\n'

    htmlToReturn_2Dform += '<tr><td><b>Example 2D f(x) Web Fitter</b></td></tr>\n'

    # HTML form for the 2D fitter
    htmlToReturn_2Dform += '<tr><td>\n'
    htmlToReturn_2Dform += '<form action="/simplefitter_2D" method="post" target=_blank>\n'

    # text data entry
{'fraction_non_alphanumeric': 0.12072999532054282, 'fraction_numerical': 0.1254094525035096, 'mean_word_length': 2.7532923617208076, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6780164', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1592, 'n_words': 421}