Get local development setup working

This commit is contained in:
Christoph Lienhard 2019-09-17 23:48:44 +02:00
parent 0e4299b8ed
commit aaec295ba4
8 changed files with 544 additions and 291 deletions

View File

@ -6,6 +6,7 @@ indent_style = space
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
indent_size = 2
[*.py] [*.py]
indent_size = 4 indent_size = 4

View File

@ -18,7 +18,7 @@ Start the flask server locally under http://127.0.0.1:5000 with the follwing scr
``` ```
./dev-start.sh ./dev-start.sh
``` ```
Observe dummy data for http://127.0.0.1:5000/kandidaten Observe dummy data for http://127.0.0.1:5000/api/kandidaten
#### For Windows #### For Windows
```set set FLASK_APP=flask-server/main.py``` ```set set FLASK_APP=flask-server/main.py```

View File

@ -3,24 +3,24 @@ from flask import Flask
app = Flask(__name__) app = Flask(__name__)
@app.route('/') @app.route('/api/')
def root(): def root():
return "Candymat Data Backend" return "Candymat Data Backend"
@app.route('/fragen') @app.route('/api/fragen')
def fragen(): def fragen():
with open('data/fragen.json', 'r') as json_file: with open('data/fragen.json', 'r') as json_file:
return json_file.read() return json_file.read()
@app.route('/kandidaten') @app.route('/api/kandidaten')
def kandidaten(): def kandidaten():
with open('data/kandidaten.json', 'r') as json_file: with open('data/kandidaten.json', 'r') as json_file:
return json_file.read() return json_file.read()
@app.route('/kategorien') @app.route('/api/kategorien')
def kategorien(): def kategorien():
with open('data/kategorien.json', 'r') as json_file: with open('data/kategorien.json', 'r') as json_file:
return json_file.read() return json_file.read()

View File

@ -10,6 +10,9 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br> The page will reload if you make edits.<br>
You will also see any lint errors in the console. You will also see any lint errors in the console.
Running the app without the backend server makes little sense.
Start it under [http://localhost:5000](http://localhost:5000) as specified in the Readme of the backend server (../backend)
### `npm test` ### `npm test`
Launches the test runner in the interactive watch mode.<br> Launches the test runner in the interactive watch mode.<br>

File diff suppressed because it is too large Load Diff

View File

@ -35,5 +35,6 @@
"last 1 firefox version", "last 1 firefox version",
"last 1 safari version" "last 1 safari version"
] ]
} },
"proxy": "http://localhost:5000"
} }

View File

@ -6,7 +6,7 @@ import { CustomAppBar } from 'components/CustomAppBar/CustomAppBar';
import { Overview } from 'components/Overview/Overview'; import { Overview } from 'components/Overview/Overview';
export const dataApi = 'http://127.0.0.1:5000' export const dataApi = '/api'
const styles = createStyles({ const styles = createStyles({

View File

@ -38,7 +38,7 @@ class ProtoExistingQuestions extends React.PureComponent<ExistingQuestionsProps,
} }
componentDidMount() { componentDidMount() {
fetch(`${dataApi}/fragen/neu`, {method: 'GET'}) fetch(`${dataApi}/fragen`, {method: 'GET'})
.then(res => res.json()) .then(res => res.json())
.then(json => this.setState({ existingQuestions: json })) .then(json => this.setState({ existingQuestions: json }))
} }