diff --git a/ahserver/__pycache__/__init__.cpython-312.pyc b/ahserver/__pycache__/__init__.cpython-312.pyc index 2a0fec9..2ecb91a 100644 Binary files a/ahserver/__pycache__/__init__.cpython-312.pyc and b/ahserver/__pycache__/__init__.cpython-312.pyc differ diff --git a/ahserver/__pycache__/version.cpython-312.pyc b/ahserver/__pycache__/version.cpython-312.pyc index eb540e4..54f97e7 100644 Binary files a/ahserver/__pycache__/version.cpython-312.pyc and b/ahserver/__pycache__/version.cpython-312.pyc differ diff --git a/ahserver/webapp.py b/ahserver/webapp.py new file mode 100644 index 0000000..fa1ed9b --- /dev/null +++ b/ahserver/webapp.py @@ -0,0 +1,31 @@ +import os, sys +import argparse +from appPublic.log import MyLogger, info, debug, warning +from appPublic.folderUtils import ProgramPath +from appPublic.jsonConfig import getConfig +from ahserver.configuredServer import ConfiguredServer +from ahserver.serverenv import ServerEnv + +def webapp(init_func): + parser = argparse.ArgumentParser(prog="Sage") + parser.add_argument('-w', '--workdir') + parser.add_argument('-p', '--port') + args = parser.parse_args() + workdir = args.workdir or os.getcwd() + p = ProgramPath() + config = getConfig(workdir, NS={'workdir':workdir, 'ProgramPath':p}) + if config.logger: + logger = MyLogger(config.logger.name or 'webapp', + levelname=config.logger.levelname or 'info', + logfile=config.logger.logfile or None) + else: + logger = MyLogger('webapp', levelname='info') + init_func() + server = ConfiguredServer(workdir=workdir) + port = args.port or config.website.port or 8080 + port = int(port) + server.run(port=port) + +if __name__ == '__main__': + from main import main + webapp(main)