|
import os |
|
import shutil |
|
from flask import Flask, send_from_directory, abort, render_template |
|
|
|
|
|
temp_dir = "/tmp/nebula_repo" |
|
|
|
|
|
def clone_and_setup_repo(): |
|
|
|
if os.path.exists(temp_dir): |
|
shutil.rmtree(temp_dir) |
|
|
|
print("Cloning the repository...") |
|
result = os.system(f"git clone https://github.com/izum00/Holy-Unblocker.git --recursive {temp_dir}") |
|
|
|
if result != 0: |
|
print("Error: Failed to clone the repository.") |
|
return |
|
|
|
|
|
os.chdir(temp_dir) |
|
os.system("npm i") |
|
os.system("cp .env.example .env") |
|
os.system("nano .env") |
|
os.system("npm run build") |
|
os.system("npm start") |
|
|
|
|
|
views_index_path = os.path.join(temp_dir, 'views', 'index.html') |
|
templates_dir = 'templates' |
|
if os.path.exists(views_index_path): |
|
if not os.path.exists(templates_dir): |
|
os.mkdir(templates_dir) |
|
shutil.move(views_index_path, os.path.join(templates_dir, 'index.html')) |
|
else: |
|
print("Error: views/index.html not found in the repository.") |
|
|
|
|
|
clone_and_setup_repo() |
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
@app.route('/') |
|
def index(): |
|
|
|
if not os.path.exists("templates/index.html"): |
|
return abort(404, description="views/index.html not found.") |
|
|
|
|
|
return render_template('index.html') |
|
|
|
|
|
@app.route('/<path:filename>') |
|
def static_files(filename): |
|
return send_from_directory('static', filename) |
|
|
|
|
|
@app.route('/check_main_js') |
|
def check_main_js(): |
|
if os.path.exists('static/main.js'): |
|
return "main.js exists." |
|
else: |
|
return "main.js does not exist." |
|
|
|
if __name__ == '__main__': |
|
|
|
app.run(host='0.0.0.0', port=7860) |
|
|