Self hosting on localhost
This tutorial will guide you on how to download your apps and run it locally on your own computer at this url: http://localhost:3000.
This is an advanced tutorial and prior experience using the terminal is expected
Downloading the code
- Go to https://github.com/MecSim/MecSimCalc-self-hosted and download the source code. You can either:
- Click on Code > Download ZIP on the Github site, and then extract the ZIP file.
- Execute the
git clonecommand in your terminal (if you have
git clone https://github.com/MecSim/MecSimCalc-self-hosted
Setting up the back-end server
- Download Python if you do not have it installed already.
- This tutorial has been tested on Python 3.8.
- Open your terminal, and
- Install all the Python libraries in
pip install -r requirements.txt
- Start the server:
python server.py does not work, try
- You should see the following printed to your terminal:
* Serving Flask app 'server' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 742-486-046
Setting up the front-end client
- Download NodeJS if you do not have it installed already.
- This tutorial has been tested on Node 16.7.
- Keep the Python server process running from before and open another terminal.
- Install all the npm packages in
- Start the front end server:
npm run build
npm run start
The following should be printed to your terminal:
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from \MecSimCalc-self-hosted\front-end\.env
- Go to http://localhost:3000 to check the website is working.
Adding your apps
- Go to https://mecsimcalc.com/app and download your apps by clicking the Download button.
Copy the downloaded
.jsonfiles into the
Refresh http://localhost:3000 and voilà, your apps should now show up.
Starting the application
After the initial installation of the application, you do not need to re-install the
npm packages. To start up your application again, do the following:
- Open a a terminal, and
npm run start.
- Open another terminal, and
- Go to http://localhost:3000.
To shut down the application, simply close the two terminal windows.
If the application is not working, check that both client and server processes are running in the terminals, and that there are no error messages in the terminals.
When your self-hosted application is ready to be deployed into production, make the following changes:
NEXT_PUBLIC_APIto the url of your Python server, if needed.
- Start the front-end server in production mode:
npm run build
npm run start