<commit_before>; Copyright (c) <NAME> <<EMAIL>>, 2013 under the terms of
; hy.



(import-from flask
             Flask render-template)

(import-from pygments highlight)
(import-from pygments.lexers PythonLexer ClojureLexer)
(import-from pygments.formatters HtmlFormatter)
(import codegen)


(def lexers {"python" (PythonLexer)
             "lisp"   (ClojureLexer)})


(def app (Flask "__main__"))  ; long story, needed hack


(route "/" [] (render-template "index.html"))


(defn colorize-python [x]
  (highlight x (index lexers "python") (HtmlFormatter)))


(defn hy-to-py [hython]
  (.to_source codegen (forge-ast "stdin" (tokenize hython))))


(decorate-with (kwapply (.route app "/format/<language>") {"methods" ["POST"]})
  (defn format-code [language]
    "Language HTML Formatter"
    (highlight
      (index request.form "code") (index lexers language) (HtmlFormatter))))


(decorate-with (kwapply (.route app "/hy2py") {"methods" ["POST"]})
  (defn translate-code []
    "Pythonic converter"
    (hy-to-py (index request.form "code"))))


(decorate-with (kwapply (.route app "/hy2pycol") {"methods" ["POST"]})
  (defn translate-code-with-color []
    "Pythonic converter"
    (colorize-python (hy-to-py (index request.form "code")))))<commit_msg>unmehing.<commit_after>; Copyright (c) <NAME> <<EMAIL>>, 2013 under the terms of
; hy.



(import-from flask
             Flask render-template)


(def app (Flask "__main__"))  ; long story, needed hack


(route "/" [] (render-template "index.html"))
{'fraction_non_alphanumeric': 0.16589250165892502, 'fraction_numerical': 0.006635700066357001, 'mean_word_length': 3.944262295081967, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1616885', 'n_tokens_mistral': 546, 'n_tokens_neox': 501, 'n_words': 139}