|
from flask import Flask, request |
|
import os |
|
import requests |
|
|
|
app = Flask(__name__) |
|
|
|
serverToken = os.environ.get("serverToken") |
|
headers = {'Authorization': os.environ.get("auth")} |
|
|
|
reqList = {} |
|
|
|
@app.route('/server', methods=['POST']) |
|
def server(): |
|
if request.json.get('serverToken') != serverToken: |
|
return {}, 400 |
|
token = request.json.get('token') |
|
URL = request.json.get('URL') |
|
postData = request.json.get('postData') |
|
reqList[token] = { URL: URL, postData: postData } |
|
return { success: True }, 200 |
|
|
|
|
|
@app.route('/client', methods=['POST']) |
|
def client(): |
|
token = request.json.get('token') |
|
data = reqList.get(token) |
|
if not data: |
|
return {}, 400 |
|
URL = data.get('URL') |
|
postData = data.get('postData') |
|
|
|
response = requests.post(URL, json=postData) |
|
|
|
return response.json() |
|
|
|
if __name__ == "__main__": |
|
app.run(host="0.0.0.0", port=7860) |