Write log files to directory

Move index file to parent directory, remove template directory
This commit is contained in:
Иван Солнцев 2024-06-04 17:25:11 +03:00
parent f7d2a675fb
commit 7697b7463e
6 changed files with 30 additions and 19 deletions

View file

@ -1,9 +1,7 @@
from logging import NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL
import testmod
from server.urlhandler import path
import testmod
SETUP = {
"setup": {

View file

@ -1,7 +1,13 @@
#!/usr/bin/python3
import os
from server.main import start
if __name__ == "__main__":
try:
os.mkdir(os.path.join(os.getcwd(), "log"))
except OSError:
pass #print("dir is exists")
start()

View file

@ -1,6 +1,7 @@
import threading
import socket
import logging
import os
import config
@ -188,8 +189,13 @@ class HTTPHandler:
def start():
logging.basicConfig(filename="main.log", filemode="a", encoding="UTF-8",
level=config.SETUP["setup"]["log_level"], format="[%(asctime)s][%(levelname)s] %(message)s")
logging.basicConfig(
filename=os.path.join(os.getcwd(), "log", "main.log"),
filemode="a",
encoding="UTF-8",
level=config.SETUP["setup"]["log_level"],
format="[%(asctime)s][%(levelname)s] %(message)s"
)
project_logotype = """
___________ _____ _____________

View file

@ -1,7 +1,18 @@
import os
def path(path="/", _type="static-file", link="index.html", methods=("GET",)):
if _type == "static-file":
return {path: (methods, _type, "static/{}".format(link))}
if _type == "redirect":
return {path: (methods, _type, link)}
return {
path: (methods, _type, os.path.join(os.getcwd(), link))
}
elif _type == "redirect":
return {
path: (methods, _type, link)
}
elif _type == "function":
return {path: (methods, _type, link)}
return {
path: (methods, _type, link)
}

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>CatNet Template</title>
</head>
<body>
<h1>Template has been loaded</h1>
<p>{template_data}</p>
</body>
</html>