Welcome to the DevSandbox! This repository is designed for you to practice and get hands-on experience with the front-end and back-end development tools we use. Whether you're new to development or just looking to refine your skills, this project will help you get familiar with essential tools.
- Python: Version 3.10 or higher.
- Node.js / npm: You can install this via nvm (Node Version Manager) for better version control. You will need Node.js version 20 or higher
- nvm: Highly recommend you install nvm to manage your Node.js versions efficiently.
Python Virtual Environment
- Create a virtual environment:
python -m venv .venv
- Activate it:
- Windows:
source .venv\Scripts\activate
- Linux:
source .venv/bin/activate
Alternatively, if you use Conda to manage your environments:
Conda Environment
- Create the environment:
conda create -n venv python=3.10
- Activate it:
conda activate venv
- Run:
pip install -r requirements.txt
- Install Node.js via nvm
- Use the required version of Node:
nvm use node
- Navigate to the front-end directory:
cd front-end-temp
- Install Depencies:
npm install
- Start the development server:
npm run dev
- src/App.jsx: Main entry point for the React app.
- src/CreateItem.jsx: Component to handle item creation.
- src/UsersList.jsx: Displays a list of users.
- Fast and efficient development server with hot module replacement.
- Minimal configuration needed.
- Supports modern JavaScript features and ES6 modules.
npm create vite@latest front-end-temp -- --template react
This command uses Vite's project creation tool to set up a new React app in a directory called front-end-temp. Try it, create a separate react app with a different name.
- Navigate to the Back-End Directory:
cd back-end
- Start the Flask application:
flask run
The Flask server will run on http://localhost:5000/
.
/api/users
: Returns a list of users in JSON format./api/items
: Allows creation of new items through a POST request.
You can access the API at http://localhost:5000/api/<endpoint>
.
- Start the Flask Back-End: Make sure the Flask back-end is running on port 5000:
python app.py
- Start the React Front-End: In another terminal, navigate to the front-end directory and start the Vite server:
npm run dev
By default:
- Flask API will be available at
http://localhost:5000/
. - React Front-End will be available at
http://localhost:5173/
.
src/App.jsx
: Main React component.src/CreateItem.jsx
: Manages item creation.src/UsersList.jsx
: Displays users fetched from the back-end.
app.py
: Main Flask application with API routes.config.py
: Environment-specific configurations (CORS, etc.).
To make the Flask app accessible on your local network, modify the host in app.py:
app.run(host='0.0.0.0', port=5000)
In vite.config.js, modify the server settings:
{
server: {
host: '0.0.0.0',
port: 5173,
proxy: {
"/api": {
target: "http://<your-ip>:5000",
changeOrigin: true,
secure: false,
},
},
},
}
Replace with your machine's IP address to access the app from other devices on the same network.