Paste #120664: python script - api server

Date: 2024/02/28 09:26:17 UTC-08:00
Type: Python

View Raw Paste Download This Paste
Copy Link


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


from flask import Flask, jsonify
import subprocess

app = Flask(__name__)

@app.route('/update', methods=['POST', 'GET'])
def update():
    try:
        subprocess.run("zip_pack.bat", shell=True, check=True)
        response = {"message": "zipped successfully", "status": 200}
    except subprocess.CalledProcessError:
        response = {"message": "Failed to execute batch file.", "status": 500}

    return jsonify(response), response['status']

if __name__ == '__main__':
    app.run(host='localhost', port=8123)


Highlighting for 'Other' types handled by Highlight.JS, which was released under the BSD 3-Clause License.