NewSimulationTest
This is a quick thing I cooked up to simulate the interaction between the JavaScript front end Python-flask backend. Basically what happens is once you press the button within the html page, it will send a get request to the python server which will handle it, sleep for a couple seconds, and then send back a response that the javascript prints to console. This basically simulates what will happen when we create our simulation.
Get Started on Windows
The essential thing to get started is to install Python
and then to install flask
. There are certain circumstances that you have installed Python
:
- Install via
Python
official package. - Install via
Visual Studio 2019
. - Install via miscellaneous ways.
Follow these steps to get started:
- Locate your installed
Python
directory and add it toPATH
environment variable. If you installedPython
withVisual Studio
, you might findPython
in%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64
. If you are not using 64-bit Windows, please remove "(x86)". - Add the
Scripts
directory in yourPython
directory toPATH
environment. - Execute the following command to install
flask
:
pip install flask
You might receive certain warnings from pip
after you installed flask
. This is because pip
created a special directory to place pip
packages. Locate this directory: %AppData%\Python\Python37\Scripts
and add it to the PATH
environment variable.
- Execute the following commands to run flask:
set FLASK_APP=pserver
set FLASK_ENV=development
flask run
Alternatively, you may double-click run_server.bat
file in lieu of manually typing these commands.
- Please note that the path of
Python
is subject to be changed due to version differences.
Optional:
Installing and setting up WSL (Windows Subsystem for Linux):
NOTE: Make sure to only install WSL1, not WSL2 so follow step 1 and then skip to step 6. So the only steps you need to follow are 1 and 6.
IMPORTANT: On the windows store, make sure you install Ubuntu 18.04 LTS.
Link: https://docs.microsoft.com/en-us/windows/wsl/install-win10
Setting up venv (virtual environment) NOTE: Don't place your env within the git repo
Installing Flask and getting the server running
Installing flask within WSL:
- You only need to follow step 1 to install flask.
- Copy and paste and then run the below two commands within wsl. You have to do this everytime you open up a new terminal:
export FLASK_APP=pserver
export FLASK_ENV=development
NOTE: You can access your windows c drive within wsl by going to /mnt/c
To run the server:
- Navigate to the top of NewSimulationTest (this repo)
- Run the following
flask run