-
Notifications
You must be signed in to change notification settings - Fork 0
Server
The application relies on its functionality on a running server written in Python.
The implementation of the server is to be found on src/server (in the future, we will have a dedicated page for its API).
In the ideal scenario, users won't even know that the server is running. They will see only a server status icon in a Footer and they will be able to change a few parameters in Settings. Also, the splash screen contains the string informing that the server is starting.
Use npm run build:server (or use npm run build:server:uv, see https://github.com/kerrambit/MolStarApp/wiki/Build-server-as-developer) to build the server using PyInstaller (the requirements.txt file is located alongside server source code). This is the whole command: pyinstaller --onefile src/server/main.py --name MolStarAppServer --distpath ./dist-server --workpath ./tmp/server --specpath ./tmp/server --clean. The built executable will be located in dist-server folder.
The application spawns the server when it is launched, but if you need to, you can start the server yourself using npm run server. This script starts the server with default parameters. Talking about parameters, let's talk about them in more detail:
- Type: String
-
Default:
localhost - Description: Specifies the host address to bind the server to
-
Example:
--host 0.0.0.0(bind to all interfaces)
- Type: Integer
-
Default:
41050 - Description: Specifies the port number to bind the server to
-
Example:
--port 8080
- Type: String
-
Default:
dev - Description: Sets the server environment mode
-
Valid values:
dev,prod(ordevelopment,production) -
Example:
--env prod
- Type: List of strings
-
Default:
[](empty list) -
Description: Specifies allowed origins for Cross-Origin Resource Sharing (CORS). Multiple origins can be provided separated by spaces. These two are always present:
file://andhttp://localhost:<PORT>. -
Example:
--cors http://localhost:3000 http://127.0.0.1:3000
- Type: Boolean flag
-
Default:
False -
Description: Enables automatic server reload when code changes are detected. Only effective in development mode (
--env dev). -
Example:
--reload(no value needed, presence of flag enables it)
./dist-server/MolStarAppServer --port 8080 --cors http://localhost:3000 --reload./dist-server/MolStarAppServer --host 0.0.0.0 --port 80 --env prod./dist-server/MolStarAppServer --env dev --cors http://localhost:3000 http://127.0.0.1:3000 http://localhost:5173 --reload