Files
Abschluss-Projekt/backend/QUICKSTART.md
2025-11-28 12:50:27 +01:00

2.1 KiB

Quick Start Guide - Python Backend

Step-by-Step Setup

1. Install Python

Make sure you have Python 3.8 or higher installed:

python --version

2. Create Virtual Environment

cd backend
python -m venv venv

3. Activate Virtual Environment

Windows:

.\venv\Scripts\Activate.ps1

Linux/Mac:

source venv/bin/activate

4. Install Dependencies

pip install -r requirements.txt

5. Verify Database Connection

Make sure MySQL is running and the database myapp exists:

CREATE DATABASE IF NOT EXISTS myapp;

6. Run the Server

python start.py

Or:

python app.py

The server should now be running at http://0.0.0.0:3000

Testing the API

Test if the server is working:

curl http://localhost:3000/api/training-projects

Common Issues

ModuleNotFoundError

If you get import errors, make sure you've activated the virtual environment and installed all dependencies.

Database Connection Error

Check that:

  • MySQL is running
  • Database credentials in app.py are correct
  • Database myapp exists

Port Already in Use

If port 3000 is already in use, modify the port in app.py:

app.run(host='0.0.0.0', port=3001, debug=True)

What Changed from Node.js

  1. Server Framework: Express.js → Flask
  2. ORM: Sequelize → SQLAlchemy
  3. HTTP Client: node-fetch → requests
  4. Package Manager: npm → pip
  5. Dependencies: package.json → requirements.txt
  6. Startup: node server.jspython app.py

Next Steps

  1. Test all API endpoints
  2. Update frontend to point to the new Python backend (if needed)
  3. Migrate any remaining Node.js-specific logic
  4. Test file uploads and downloads
  5. Test YOLOX training functionality

File Structure Comparison

Before (Node.js):

backend/
├── server.js
├── package.json
├── routes/api.js
├── models/*.js
└── services/*.js

After (Python):

backend/
├── app.py
├── requirements.txt
├── routes/api.py
├── models/*.py
└── services/*.py