-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.py
29 lines (26 loc) · 1.08 KB
/
server.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
import random
import os
from flask import Flask, jsonify
from flask_cors import CORS, cross_origin
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
aiLines = open("./ai.txt", encoding="utf8").readlines()
realLines = open("./real.txt", encoding="utf8").readlines()
@app.route('/api/', methods=['GET'])
@cross_origin()
def result():
rng = random.SystemRandom()
if(rng.random() > 0.5):
randomString = random.SystemRandom().choice(aiLines)
if randomString.strip() != "====================" and randomString.strip() != " " and randomString.strip() != "\n" and randomString.strip() != "@Jerma985" and randomString.strip() != ":":
print(randomString.strip())
return jsonify({'string': randomString.strip(), 'result': 'ai'})
else:
result()
else:
randomString = random.SystemRandom().choice(realLines)
return jsonify({'string': randomString.strip(), 'result': 'real'})
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)