<commit_before>import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import os
import os.path
import sys
import importlib

import #APPNAME.config.routes 
import #APPNAME.config.settings

#sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), "../config" )) 

from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)

copow_handlers = #APPNAME.config.routes.handlers
copow_settings = #APPNAME.config.settings.webserver

def init_controllers(app):
	path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "controllers")
	print("path ffor controllers: ", path)
	handler_list = []
	exclude_list = [
		"base_controller", 
		"welcome_controller", 
		"error_controller", 
		"login_controller", 
		"logout_controller",
		"dispatch_controller"
	]
	for f in os.listdir(path):
		fname, fext = os.path.splitext(f)
		if not fname.startswith("__") and fname not in exclude_list:
			print(fname)
			# create RESTful routes for each controller.
			# 1. load the controller
			# convention for the controller module name is: name_controller
			controller_name = fname.split("_")[0].capitalize()+"Controller"
			controller_short_name = fname.split("_")[0]
			import_module_str = "atest.controllers." + fname
			#print(import_module_str)
			con = importlib.import_module(import_module_str)
			#print(con)
			controller = getattr(con, controller_name)
			#print(controller)
			# 1st REST 
			onerest = r"/"+controller_short_name
			handler_list.append((onerest, controller))
			tworest = r"/"+controller_short_name+"/([0-9a-zA-Z]+)"<commit_msg>added a better docstring for init_controllers()<commit_after>import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import os
import os.path
import sys
import importlib

import #APPNAME.config.routes 
import #APPNAME.config.settings

#sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), "../config" )) 

from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)

copow_handlers = #APPNAME.config.routes.handlers
copow_settings = #APPNAME.config.settings.webserver

def init_controllers(app):
	"""
		automatically adds RESTful routes for eacg controller in controllers/
		which is named according to the convention: name_controller

		Automatically calls the right cotroller->CRUDMethod.
        According to this mapping table:
        **********
        * ACTION:
        **********
        in General:
        HTTP    Method      CRUD Action Description
        -----------------------------------------------
        POST    CREATE      Create a new resource
        GET     RETRIEVE    Retrieve a representation of a resource
        PUT     UPDATE      Update a resource
        DELETE  DELETE      Delete a resource

        PUT and DELETE must be handled with a POST request and an
        addiotional HTTP Parameter: REQUEST_TYPE
        set to PUT or DELETE accordingly.

        Meaning a call to domain:port/controller/([someting]+)
        Where something is usually an ID
        HTTP get        => will call controller.show(something)
        HTTP POST       => will call controller.create(something)
        HTTP PUT        => will call controller.edit(something)
        HTTP DELETE     => will call controller.delete(something)
        and a call to domain:port/controller/
        HTTP get        => will call controller.list()
        HTTP POST       => will call Nothing, yet.
        HTTP PUT        => will call controller.replace_all() [empty by default]
        HTTP DELETE     => will call controller.delete_all()

        ***********
        * FORMAT:
        ***********
        Also all reuests can have an Accept: HTTP header field which must be parsed by the
        controller itself.
        Example:    Accept:      text/json

        
	"""
	path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "controllers")
	print("path ffor controllers: ", path)
	handler_list = []
	exclude_list = [
		"base_controller", 
		"welcome_controller", 
		"error_controller", 
		"login_controller", 
		"logout_controller",
		"dispatch_controller"
	]
	for f in os.listdir(path):
		fname, fext = os.path.splitext(f)
		if not fname.startswith("__") and fname not in exclude_list:
			print(fname)
			# create RESTful routes for each controller.
			# 1. load the controller
			# convention for the controller module name is: name_controller
			controller_name = fname.split("_")[0].capitalize()+"Controller"
			controller_short_name = fname.split("_")[0]
			import_module_str = "atest.controllers." + fname
			#print(import_module_str)
			con = importlib.import_module(import_module_str)
			#print(con)
			controller = getattr(con, controller_name)
			#print(controller)
			# 1st REST 
			onerest = r"/"+controller_short_name
			handler_list.append((onerest, controller))
			tworest = r"/"+controller_short_name+"/([0-9a-zA-Z]+)"
{'fraction_non_alphanumeric': 0.11610711430855315, 'fraction_numerical': 0.003996802557953637, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '5241552', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1484, 'n_words': 395}