mirror of
https://github.com/SqrtMinusOne/sqrtminusone.github.io.git
synced 2025-12-10 15:53:03 +03:00
feat: some kind of deployer
This commit is contained in:
parent
b15e644874
commit
a287df963a
1 changed files with 25 additions and 0 deletions
25
deployer.py
Normal file
25
deployer.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from flask_httpauth import HTTPTokenAuth
|
||||
|
||||
|
||||
def create_app():
|
||||
load_dotenv()
|
||||
app = Flask(__name__)
|
||||
auth = HTTPTokenAuth(scheme='Bearer')
|
||||
|
||||
@auth.verify_token
|
||||
def verify_token(token):
|
||||
return token == os.environ['TOKEN']
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
@auth.login_required
|
||||
def deploy():
|
||||
subprocess.run(['git', 'fetch', 'origin'])
|
||||
subprocess.run(['git', 'checkout', 'origin/gh-pages'])
|
||||
|
||||
return app
|
||||
Loading…
Add table
Reference in a new issue