You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
579 B
21 lines
579 B
import os
|
|
import subprocess
|
|
|
|
from dotenv import load_dotenv
|
|
from flask import Flask, jsonify, request
|
|
|
|
|
|
def create_app():
|
|
load_dotenv()
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/", methods=["POST"])
|
|
def deploy():
|
|
if request.headers["Authorization"] != f'Bearer {os.getenv("TOKEN")}':
|
|
return jsonify({"message": "Invalid token"}), 401
|
|
subprocess.run(["git", "pull"], cwd=os.getenv("FOLDER"))
|
|
subprocess.run(["git", "checkout", "gh-pages"], cwd=os.getenv("FOLDER"))
|
|
return jsonify({"message": "Deployed"}), 200
|
|
|
|
return app
|