This application predicts lap times for the racing simulation game Assetto Corsa. It includes a Flask backend and a React frontend. Follow the instructions below to get the application running on your system.
Before you start, ensure you have the following installed:
- Python (3.8 or later)
- Flask
- Node.js and npm
For a smoother development experience and to avoid potential conflicts with other Python projects, we recommend setting up a virtual environment for this project. A virtual environment is an isolated Python environment where the dependencies for a specific project are installed without affecting the global Python installation.
python3 -m venv (name of environment)After creating the virtual environment, you need to activate it (<venv> must be replaced by thte path to the directory containing the virtual environment):
-
For Windows Command Prompt:
<venv>\Scripts\activate
-
For Windows PowerShell:
<venv>\Scripts\Activate.ps1
-
For Linux/Mac:
source <venv>/bin/activate
Once the virtual environment is activated, install the project dependencies using the requirements.txt file:
pip install -r requirements.txtThis will install all the necessary Python packages for the project.
First, navigate to the root directory of the project. Then, set the environment variable for the Flask application using the command line. The command you use depends on your operating system:
-
For Windows Command Prompt:
set FLASK_APP=src\server.py
-
For Windows PowerShell:
$env:FLASK_APP="src\server.py"
Note: The PowerShell command mistakenly had
"hello"as the value. It should be"src\server.py"to correctly point to the Flask application. -
For Linux/Mac:
export FLASK_APP=src/app.pyEnsure you are using the correct path to the Flask application file. The example shows
src/app.py, but adjust it according to your project's structure.
Once the environment variable is set, you can start the Flask server with the following command:
flask runThere's no need to specify app after flask run as the FLASK_APP environment variable already points to the application.
The user interface is built with React. To start it, navigate to the ui directory and install the dependencies if you haven't done so:
cd ui
npm installThen, run the UI:
npm startThis will launch the React application, typically available at http://localhost:3000 in your web browser.