-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebService.py
More file actions
31 lines (27 loc) · 762 Bytes
/
WebService.py
File metadata and controls
31 lines (27 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!flask/bin/python
from logic import Logic
from flask_cors import CORS, cross_origin
from flask import Flask
from flask import jsonify
from flask import request
app = Flask(__name__)
CORS(app)
@app.route('/Text', methods=['GET'])
def Text():
return jsonify({
"opening":'<br/>'.join(Logic.OpeningSpiel()),
"numberOfHeroes":Logic.NumberOfHeroesText()
})
@app.route('/Generate', methods=['POST'])
def Generate():
content = request.get_json()
heroes = Logic.GetHeroes(int(content['numberOfHeroes']))
ship = Logic.GetShip()
threat = Logic.GetThreat()
return jsonify({
"heroes": '<br/>'.join(heroes),
"ship": '<br/>'.join(ship),
"threat": threat
})
if __name__ == '__main__':
app.run(debug=True)