File size: 712 Bytes
dcb132a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys

import flask
import src.functions.config

restartBP = flask.Blueprint("restart", __name__)


@restartBP.route("/api/v1/restart")
def restartFunction():
    config = src.functions.config.readConfig()
    secret = flask.request.args.get("secret")
    if secret == config.get("secret_key"):
        os.execv(sys.executable, [sys.executable] + sys.argv)
    else:
        return (
            flask.jsonify(
                {
                    "code": 401,
                    "content": None,
                    "message": "The secret key provided was incorrect.",
                    "success": False,
                }
            ),
            401,
        )