2024-07-03 14:15:22 +03:00
|
|
|
import os
|
2024-07-03 14:06:19 +03:00
|
|
|
import logging
|
2024-02-25 01:42:17 +03:00
|
|
|
|
2024-09-15 15:11:51 +03:00
|
|
|
from server.common import HandlerType, HTTPMethod
|
|
|
|
from server.urlhandler import Path
|
2024-06-04 17:25:11 +03:00
|
|
|
import testmod
|
2024-02-25 01:42:17 +03:00
|
|
|
|
2024-09-15 15:11:51 +03:00
|
|
|
|
2023-12-29 02:13:10 +03:00
|
|
|
SETUP = {
|
2024-02-26 02:21:00 +03:00
|
|
|
"setup": {
|
2024-07-03 14:06:19 +03:00
|
|
|
"log_to_file": False,
|
|
|
|
"log_level": logging.DEBUG
|
2024-02-26 02:21:00 +03:00
|
|
|
},
|
2023-12-29 02:13:10 +03:00
|
|
|
"server": {
|
|
|
|
"port": 8080,
|
|
|
|
}
|
|
|
|
}
|
2024-02-25 01:42:17 +03:00
|
|
|
|
2024-09-15 15:11:51 +03:00
|
|
|
|
2024-07-03 14:06:19 +03:00
|
|
|
if SETUP["setup"]["log_to_file"]:
|
2024-07-03 14:15:22 +03:00
|
|
|
logging.basicConfig(filename=os.path.join(os.getcwd(), "log", "main.log"), filemode="a", encoding="UTF-8",
|
2024-07-03 14:06:19 +03:00
|
|
|
level=SETUP["setup"]["log_level"],
|
2024-10-03 14:26:15 +03:00
|
|
|
format="[%(asctime)s][%(levelname)s][%(name)s] %(message)s")
|
2024-07-03 14:06:19 +03:00
|
|
|
else:
|
|
|
|
logging.basicConfig(encoding="UTF-8", level=SETUP["setup"]["log_level"],
|
2024-10-03 14:26:15 +03:00
|
|
|
format="[%(asctime)s][%(levelname)s][%(name)s] %(message)s")
|
2024-07-03 14:06:19 +03:00
|
|
|
|
2024-09-15 15:11:51 +03:00
|
|
|
|
2024-02-25 01:42:17 +03:00
|
|
|
urls = [
|
2024-09-15 15:11:51 +03:00
|
|
|
Path("/", HandlerType.STATIC_FILE, "index.html"),
|
|
|
|
Path("/func", HandlerType.FUNCTION, testmod.work, HTTPMethod.GET|HTTPMethod.POST),
|
|
|
|
Path("/func1", HandlerType.FUNCTION, testmod.work2, HTTPMethod.POST)
|
2024-02-25 01:42:17 +03:00
|
|
|
]
|