yuripeyamashita
commited on
Commit
•
27407e5
1
Parent(s):
4bc235e
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,37 @@
|
|
1 |
from flask import Flask, request
|
2 |
-
from time import sleep
|
3 |
import os
|
4 |
import requests
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
|
|
8 |
headers = {'Authorization': os.environ.get("auth")}
|
9 |
-
print(headers)
|
10 |
|
11 |
-
|
12 |
|
13 |
-
@app.route(
|
14 |
-
def
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
-
if __name__ == "__main__":
|
22 |
-
app.run(host="0.0.0.0", port=7860)
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
|
|
|
1 |
from flask import Flask, request
|
|
|
2 |
import os
|
3 |
import requests
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
7 |
+
serverToken = os.environ.get("serverToken")
|
8 |
headers = {'Authorization': os.environ.get("auth")}
|
|
|
9 |
|
10 |
+
reqList = {}
|
11 |
|
12 |
+
@app.route('/server', methods=['POST'])
|
13 |
+
def server():
|
14 |
+
if request.json.get('serverToken') != serverToken:
|
15 |
+
return {}, 400
|
16 |
+
token = request.json.get('token')
|
17 |
+
URL = request.json.get('URL')
|
18 |
+
postData = request.json.get('postData')
|
19 |
+
reqList[token] = { URL: URL, postData: postData }
|
20 |
+
return { success: True }, 200
|
21 |
|
|
|
|
|
22 |
|
23 |
+
@app.route('/client', methods=['POST'])
|
24 |
+
def client():
|
25 |
+
token = request.json.get('token')
|
26 |
+
data = reqList.get(token)
|
27 |
+
if not data:
|
28 |
+
return {}, 400
|
29 |
+
URL = data.get('URL')
|
30 |
+
postData = data.get('postData')
|
31 |
+
|
32 |
+
response = requests.post(URL, json=postData)
|
33 |
+
|
34 |
+
return response.json()
|
35 |
|
36 |
+
if __name__ == "__main__":
|
37 |
+
app.run(host="0.0.0.0", port=7860)
|