feat: Try to use a separate thread for tlsa generation

This commit is contained in:
Nathan Woodburn 2024-02-25 14:22:28 +11:00
parent 93a3e95380
commit ed222714ce
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

14
main.py
View File

@ -7,6 +7,7 @@ import json
import render
import secrets
import nginx
import threading
app = Flask(__name__)
dotenv.load_dotenv()
@ -281,14 +282,17 @@ def publish():
if 'tlsa' in data:
# Site is already published
return redirect('/site')
def generate_ssl_and_write_nginx():
tlsa = nginx.generate_ssl(i['name'])
data['tlsa'] = tlsa
with open(f'sites/{i["name"]}.json', 'w') as file:
json.dump(data, file)
nginx.write_nginx_conf(i['name'])
tlsa = nginx.generate_ssl(i['name'])
data['tlsa'] = tlsa
with open(f'sites/{i["name"]}.json', 'w') as file:
json.dump(data, file)
nginx.write_nginx_conf(i['name'])
threading.Thread(target=generate_ssl_and_write_nginx).start()
return redirect('/site')
response = make_response(redirect('/'))
response.set_cookie('auth', '', expires=0)