Browse Source

dunno

master
Marc 3 years ago
parent
commit
3b72afff08
4 changed files with 11 additions and 6 deletions
  1. 8
      README.md
  2. 2
      backend/project.py
  3. 3
      frontend/package.json
  4. 4
      frontend/src/App.js

8
README.md

@ -1,6 +1,8 @@
## Requirements ## Requirements
npm >= 6.0 npm >= 6.0
in /frontend:
npm install, um die notwendigen node_modules zu installieren
pip: pip:
* wheel * wheel
@ -18,11 +20,11 @@ After=network.target
[Service] [Service]
User=maintenance User=maintenance
Group=www-data Group=www-data
WorkingDirectory=/path/to/project
Environment="PATH=/path/to/project/bin"
WorkingDirectory=/path/to/project/backend
Environment="PATH=/path/to/project/venv/backend/bin"
#remove --reload when site is ready #remove --reload when site is ready
#reload restarts workers when code changes #reload restarts workers when code changes
ExecStart=/path/to/project/bin/gunicorn --reload --workers 3 --bind 0.0.0.0:8900 wsgi:app
ExecStart=/path/to/project/backend/venv/bin/gunicorn --reload --workers 3 --bind 0.0.0.0:8900 wsgi:app
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

2
backend/project.py

@ -1,9 +1,11 @@
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
import time import time
app = Flask(__name__) app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///primemeat.db" app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///primemeat.db"
CORS(app)
# DB # DB
db = SQLAlchemy(app) db = SQLAlchemy(app)

3
frontend/package.json

@ -12,7 +12,8 @@
"react-chartjs-2": "^2.10.0", "react-chartjs-2": "^2.10.0",
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
"react-scripts": "4.0.0", "react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
"web-vitals": "^0.2.4",
"yarn": "^1.22.10"
}, },
"scripts": { "scripts": {
"start": "PORT=4000 react-scripts start", "start": "PORT=4000 react-scripts start",

4
frontend/src/App.js

@ -32,7 +32,7 @@ function App() {
const [isLoaded, setIsLoaded] = useState(false); const [isLoaded, setIsLoaded] = useState(false);
useEffect(() => { useEffect(() => {
fetch('/api/umsatz')
fetch('http://127.0.0.1:8900/api/umsatz')
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
setIsLoaded(true); setIsLoaded(true);
@ -42,7 +42,7 @@ function App() {
setIsLoaded(true); setIsLoaded(true);
setError(error); setError(error);
}); });
fetch('/time')
fetch('http://127.0.0.1:8900/time')
.then(result => result.json()) .then(result => result.json())
.then(data => { .then(data => {
setCurrentTime(sec2time(data.time)); setCurrentTime(sec2time(data.time));

Loading…
Cancel
Save