feat: Try to use a separate thread for tlsa generation
This commit is contained in:
parent
93a3e95380
commit
ed222714ce
14
main.py
14
main.py
@ -7,6 +7,7 @@ import json
|
|||||||
import render
|
import render
|
||||||
import secrets
|
import secrets
|
||||||
import nginx
|
import nginx
|
||||||
|
import threading
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
@ -281,15 +282,18 @@ def publish():
|
|||||||
if 'tlsa' in data:
|
if 'tlsa' in data:
|
||||||
# Site is already published
|
# Site is already published
|
||||||
return redirect('/site')
|
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'])
|
threading.Thread(target=generate_ssl_and_write_nginx).start()
|
||||||
data['tlsa'] = tlsa
|
|
||||||
with open(f'sites/{i["name"]}.json', 'w') as file:
|
|
||||||
json.dump(data, file)
|
|
||||||
nginx.write_nginx_conf(i['name'])
|
|
||||||
return redirect('/site')
|
return redirect('/site')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = make_response(redirect('/'))
|
response = make_response(redirect('/'))
|
||||||
response.set_cookie('auth', '', expires=0)
|
response.set_cookie('auth', '', expires=0)
|
||||||
return response
|
return response
|
||||||
|
Loading…
Reference in New Issue
Block a user