Ver Fonte

set static and template directory before importing justpy

Falko Schindler há 2 anos atrás
pai
commit
f978b2981a
1 ficheiros alterados com 3 adições e 2 exclusões
  1. 3 2
      nicegui/run.py

+ 3 - 2
nicegui/run.py

@@ -12,6 +12,9 @@ from uvicorn.supervisors import ChangeReload, Multiprocess
 from . import globals
 from .config import Config
 
+os.environ['STATIC_DIRECTORY'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static')
+os.environ['TEMPLATES_DIRECTORY'] = os.path.join(os.environ['STATIC_DIRECTORY'], 'templates')
+
 
 def run(self, *,
         host: str = os.environ.get('HOST', '0.0.0.0'),
@@ -40,8 +43,6 @@ def run(self, *,
     )
     os.environ['HOST'] = globals.config.host
     os.environ['PORT'] = str(globals.config.port)
-    os.environ['STATIC_DIRECTORY'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static')
-    os.environ['TEMPLATES_DIRECTORY'] = os.path.join(os.environ['STATIC_DIRECTORY'], 'templates')
 
     if inspect.stack()[-2].filename.endswith('spawn.py'):
         return