ANSI escape sequences

This commit is contained in:
drmext 2023-05-05 16:24:50 +00:00
parent 7d1245d474
commit 21872c04f9
No known key found for this signature in database
GPG Key ID: F1ED48FFE79A6961
2 changed files with 26 additions and 19 deletions

View File

@ -140,7 +140,8 @@ async def core_process_request(request):
request.is_binxml = KBinXML.is_binary_xml(xml_dec)
if config.verbose_log:
print("Request:")
print()
print("\033[94mREQUEST\033[0m:")
print(xml_text)
model_parts = (root.attrib["model"], *root.attrib["model"].split(":"))
@ -173,7 +174,7 @@ async def core_prepare_response(request, xml):
xml_binary = binxml.to_text().encode("utf-8") # TODO: Proper encoding
if config.verbose_log:
print("Response:")
print("\033[91mRESPONSE\033[0m:")
print(binxml.to_text())
response_headers = {"User-Agent": "EAMUSE.Httpac/1.0"}

View File

@ -3,7 +3,7 @@ from urllib.parse import urlunparse, urlencode
import uvicorn
import ujson as json
from os import path
from os import name, path
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
@ -65,28 +65,34 @@ else:
return RedirectResponse(url="/config")
# Enable ANSI escape sequences
if name == "nt":
import ctypes
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
if __name__ == "__main__":
print(" __ __ _ ")
print("| \/ | ___ _ __ | | _____ _ _ ")
print("| |\/| |/ _ \| '_ \| |/ / _ \ | | |")
print("| | | | (_) | | | | < __/ |_| |")
print("|_| |_|\___/|_| |_|_|\_\___|\__, |")
print(" |___/ ")
print(" ____ _ ")
print("| __ ) _ _ ___(_)_ __ ___ ___ ___ ")
print("| _ \| | | / __| | '_ \ / _ \/ __/ __|")
print("| |_) | |_| \__ \ | | | | __/\__ \__ \\")
print("|____/ \__,_|___/_|_| |_|\___||___/___/")
print(
"""
"""
)
print()
print("Game Config:")
print(f"<services>{server_services_url}</services>")
print('<url_slash __type="bool">1</url_slash>')
print("\033[1mGame Config\033[0m:")
print(f"<services>\033[92m{server_services_url}\033[0m</services>")
print('<url_slash __type="bool">\033[92m1\033[0m</url_slash>')
print()
if webui:
print("Web Interface:")
print("\033[1mWeb Interface\033[0m:")
print(f"http://{server_address}/webui/")
print()
print("Source Repository:")
print("\033[1mSource Repository\033[0m:")
print("https://github.com/drmext/MonkeyBusiness")
print()
uvicorn.run("pyeamu:app", host=config.ip, port=config.port, reload=True)