Skip to content

aba17002/NewSimulationTest

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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:

  1. Locate your installed Python directory and add it to PATH environment variable. If you installed Python with Visual Studio, you might find Python in %ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64. If you are not using 64-bit Windows, please remove "(x86)".
  2. Add the Scripts directory in your Python directory to PATH environment.
  3. 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.

  1. 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.

  1. 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

Link: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-18-04

Installing Flask and getting the server running

Installing flask within WSL:

  1. You only need to follow step 1 to install flask.
  2. 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

Link: https://www.digitalocean.com/community/tutorials/how-to-make-a-web-application-using-flask-in-python-3

NOTE: You can access your windows c drive within wsl by going to /mnt/c

To run the server:

  1. Navigate to the top of NewSimulationTest (this repo)
  2. Run the following
    flask run

About

This is a quick thing I cooked up to simulate the interaction between the JavaScript front end and Python-flask backend for our purposes.

Resources

Stars

Watchers

Forks

Releases

No releases published