-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 742 Bytes
/
main.py
File metadata and controls
31 lines (23 loc) · 742 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
import os
from flask import Flask, request, jsonify
import GA
import requests
app = Flask(__name__)
app.config['TIMEOUT'] = 30
@app.route('/', methods=['GET'])
def index():
return "API is Online"
@app.route("/schedule", methods=['POST'])
def generate_schedule():
test = request.json
object = GA.GeneticAlgorithm(10,test)
result = object.run()
response = requests.post('http://localhost:5000/jadwal', json=result)
response_data = {}
if response:
response_data = {"status": "success"}
else:
response_data = {"status": "Not success at generating"}
return jsonify(response_data)
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))