pub1c-web/app/api/apache_restart.py

29 lines
735 B
Python
Raw Normal View History

2021-10-07 10:54:49 +00:00
import os
from flask_restful import Resource, abort
from app.glob import get_config
apache_restart_flagfile = 'restart_apache'
class ApacheRestartFlag(Resource):
def get(self):
cfg = get_config()
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
if not os.path.isfile(flagfile):
abort(404, message='not found')
return {
'message': 'found'
}
def put(self):
cfg = get_config()
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
if os.path.isfile(flagfile):
return '', 304
with open(flagfile, 'a'):
pass
return {
'message': 'success'
}