bugfix
This commit is contained in:
parent
71be8cf32c
commit
fa18dce549
Binary file not shown.
Binary file not shown.
31
ahserver/webapp.py
Normal file
31
ahserver/webapp.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user