-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.py
More file actions
42 lines (37 loc) · 1.01 KB
/
worker.py
File metadata and controls
42 lines (37 loc) · 1.01 KB
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
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
from flask import Flask, request
import json
import os
import hashlib
app = Flask(__name__)
secretkey = ''
try:
keyfile = open('secretkey', 'r')
secretkey = keyfile.read() # md5^100 of asdf
keyfile.close()
except IOError:
print('Key file not found')
secretkey='912ec803b2ce49e4a541068d495ab570' # md5 of asdf
@app.route('/submit', methods=['POST'])
def submit():
try:
if hashlib.sha256(request.form['data']+secretkey) == request.form['hash']:
jsonret = json.loads(request.form['data'])
# your source is jsonret['source']
else:
return 'EAUTH' # error : auth does not match
except KeyError:
return 'EMISS' # error : missing some key
return 'SSUCC'
@app.route('/add', methods=['POST'])
def add():
try:
if hashlib.sha256(request.form['data']+secretkey) == request.form['hash']:
# add problem
else:
return 'EAUTH' # error : auth does not match
except KeyError:
return 'EMISS' # error : missing some key
return 'asdf'
if __name__ == '__main__':
app.run(debug=True, port=5000)