Skip to content

Commit

Permalink
htagweb.__main__ accept a fqn as defaut home
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Jul 29, 2023
1 parent ec0a669 commit 3ca11a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion htagweb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@

import uvicorn
from . import HtagServer
import sys

app=HtagServer(debug=True,ssl=False)
if __name__=="__main__":
if len(sys.argv)==1:
app=HtagServer(None, debug=True,ssl=False)
elif len(sys.argv)==2:
app=HtagServer(sys.argv[1], debug=True,ssl=False)
else:
print("bad call (only one paremeter is possible (a fqn, ex: 'main:App'))")
sys.exit(-1)
uvicorn.run(app)
9 changes: 8 additions & 1 deletion htagweb/htagserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ async def on_connect(self, websocket):
if not path:
if websocket.app.index:
# there is a main htag'class for '/'
klass=websocket.app.index
if isinstance(websocket.app.index,str):
path=websocket.app.index
if ":" in path:
klass=getClass(path)
else:
klass=getClass(path+":App")
else:
klass=websocket.app.index
else:
try:
klass=getClass("index:App")
Expand Down

0 comments on commit 3ca11a8

Please sign in to comment.