<commit_before>#lang scheme
(require web-server/servlet
         web-server/servlet-env)

(provide 
 (all-from-out web-server/servlet)
 (except-out (all-from-out scheme) #%module-begin)
 (rename-out [web-module-begin #%module-begin]))

(define extra-files-path #f)
(define launch-browser? #t)

(provide/contract
 (static-files-path ((or/c string? path?) . -> . void?)))
(define (static-files-path path)
  (set! extra-files-path 
        (if (path? path) 
            path
            (string->path path))))

(provide no-web-browser)
(define (no-web-browser)
  (set! launch-browser? false))

(define-syntax (web-module-begin stx)
  (syntax-case stx ()
    [(_ body ...)
     (with-syntax ([start (datum->syntax stx 'start)])
       #`(#%module-begin
          body ...
          (provide/contract (start (request? . -> . response?)))
          (if extra-files-path
              (serve/servlet start
                             #:extra-files-path extra-files-path
                             #:launch-browser? launch-browser?)
              (serve/servlet start
                             #:launch-browser? launch-browser?))
          ))]))<commit_msg>Trying to check for missing start identifier.<commit_after>#lang scheme
(require web-server/servlet
         web-server/servlet-env
         (for-syntax syntax/kerncase))

(provide 
 (all-from-out web-server/servlet)
 (except-out (all-from-out scheme) #%module-begin)
 (rename-out [web-module-begin #%module-begin]))

(define extra-files-path #f)
(define launch-browser? #t)

(provide/contract
 (static-files-path ((or/c string? path?) . -> . void?)))
(define (static-files-path path)
  (set! extra-files-path 
        (if (path? path) 
            path
            (string->path path))))

(provide no-web-browser)
(define (no-web-browser)
  (set! launch-browser? false))




(define-syntax (web-module-begin stx)
  
  ;; check-for-start: syntax (listof syntax) -> (listof syntax)
  ;; Checks to see that the user has defined a request handler named "start".
  ;; Returns a list of the expanded syntax.
  (define (check-for-start start-stx body-stxs)
    (define (id-for-start? ids)
      (ormap (lambda (id)
               (and (identifier? id)
                    (free-identifier=? id start-stx)))
             ids))
    
    ;; FIXME: this is not quite ready for prime time yet.
    (let ([expanded-bodies
           (let loop ([defns body-stxs])
             (apply append
                    (map (lambda (defn)
                           (let ([d (local-expand
                                     defn
                                     'module
                                     (kernel-form-identifier-list))])
                             (syntax-case d (define-values define-syntaxes begin)
                               [(begin defn ...)
                                (loop (syntax->list (syntax (defn ...))))]
                               [(define-values (id ...) body)
                                (list d)]
                               [(define-values . rest)
                                (list d)]
                               [(define-syntaxes (id ...) body)
                                (list d)]
                               [(define-syntaxes . rest)
                                (list d)]
                               [_else
                                (list d)])))
                         defns)))])
      (let ([ids (apply append (map (lambda (b)
                                      (let ([result
                                             (syntax-case b ()
                                               [(define-values (id ...) . __)
                                                (syntax->list #'(id ...))]
                                               [_ '()])])
                                        result))
                                    expanded-bodies))])
        (unless (id-for-start? ids)
          (raise-syntax-error #f "required \"start\" request handler needs to be defined" stx))
        (values expanded-bodies))))
  
  (syntax-case stx ()
    [(_ body ...)
     (let ([start-stx (datum->syntax stx 'start)])
       (with-syntax ([start start-stx]
                     #;[(expanded-body ...)
                        (check-for-start start-stx (syntax->list #'(body ...)))])
         #`(#%module-begin
            body ...
            (provide/contract (start (request? . -> . response?)))
            (if extra-files-path
                (serve/servlet start
                               #:extra-files-path extra-files-path
                               #:launch-browser? launch-browser?)
                (serve/servlet start
                               #:launch-browser? launch-browser?)))))]))
{'fraction_non_alphanumeric': 0.13617200674536256, 'fraction_numerical': 0.0, 'mean_word_length': 1.246685606060606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6181754', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1228, 'n_words': 300}