/
app.py
35 lines (28 loc) · 843 Bytes
/
app.py
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
32
33
34
35
from flask import Flask
from flask import request
from flask import jsonify
import json
from source import entryPoint
app = Flask(__name__)
@app.route('/')
def default():
return "hello"
@app.route('/hook',methods=['POST'])
def github_hook():
print("github payload received")
requestData = request.json
return entryPoint.main(requestData)
@app.errorhandler(500)
def internal_error(error):
print(error)
return jsonify(success=False,error=str(error)),500
@app.errorhandler(404)
def not_found(error):
prit(error)
return jsonify(success=False,error=str(error)),404
def load_config():
with open('appConfig.json') as config_file:
return json.load(config_file)
if __name__ == '__main__':
config = load_config()
app.run(host=config.get('host', 'localhost'), port=config.get('port', 8000))