start webui
This commit is contained in:
@@ -8,13 +8,10 @@ WORKDIR /opt/app
|
|||||||
COPY . /opt/app/
|
COPY . /opt/app/
|
||||||
|
|
||||||
# Install any needed packages specified in requirements.txt
|
# Install any needed packages specified in requirements.txt
|
||||||
RUN pip install --no-cache-dir Flask requests python-dotenv beautifulsoup4
|
RUN pip install --no-cache-dir Flask requests python-dotenv beautifulsoup4 gunicorn
|
||||||
|
|
||||||
# Make port 8182 available to the world outside this container
|
# Make port 8182 available to the world outside this container
|
||||||
EXPOSE 8182
|
EXPOSE 8182
|
||||||
|
|
||||||
# Define environment variable
|
# Run Gunicorn
|
||||||
ENV FLASK_APP=metaproxy.py
|
CMD ["gunicorn", "--bind", "0.0.0.0:8182", "app:app"]
|
||||||
|
|
||||||
# Run app.py when the container launches
|
|
||||||
CMD ["flask", "run", "--host=0.0.0.0", "--port=8182"]
|
|
||||||
|
|||||||
@@ -1,13 +1,39 @@
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
from flask import Flask, Response, request
|
from flask import Flask, Response, render_template, request, redirect, url_for
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
app = Flask(__name__)
|
# Mock data for configuration
|
||||||
|
config = {
|
||||||
|
"excluded_countries": os.getenv('EXCLUDED_COUNTRIES', '[]'),
|
||||||
|
"preferred_protocols": os.getenv('PREFERRED_PROTOCOLS', '["https", "http"]'),
|
||||||
|
"preferred_types": os.getenv('PREFERRED_TYPES', '["https", "http"]'),
|
||||||
|
"min_preference": os.getenv('MIN_PREFERENCE', '0')
|
||||||
|
}
|
||||||
|
|
||||||
|
@app.route('/dash/config', methods=['GET', 'POST'])
|
||||||
|
def config():
|
||||||
|
if request.method == 'POST':
|
||||||
|
config['excluded_countries'] = request.form['excluded_countries']
|
||||||
|
config['preferred_protocols'] = request.form['preferred_protocols']
|
||||||
|
config['preferred_types'] = request.form['preferred_types']
|
||||||
|
config['min_preference'] = request.form['min_preference']
|
||||||
|
return redirect(url_for('config'))
|
||||||
|
return render_template('config.html', **config)
|
||||||
|
|
||||||
|
@app.route('/dash/stats')
|
||||||
|
def stats():
|
||||||
|
return render_template('stats.html')
|
||||||
|
|
||||||
|
@app.route('/dash/logs')
|
||||||
|
def logs():
|
||||||
|
return render_template('logs.html')
|
||||||
|
|
||||||
@app.route('/metalink')
|
@app.route('/metalink')
|
||||||
def get_metalink():
|
def get_metalink():
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
metaproxy:
|
metaproxy:
|
||||||
@@ -7,5 +8,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data:/opt/app/data
|
- ./data:/opt/app/data
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=production
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|||||||
31
templates/base.html
Normal file
31
templates/base.html
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>MetaProxy Dashboard</title>
|
||||||
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" href="/dash/config">Configuration</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/dash/stats">Statistics</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/dash/logs">Error Logs</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
26
templates/config.html
Normal file
26
templates/config.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="tab-pane fade show active">
|
||||||
|
<h2>Configuration</h2>
|
||||||
|
<form method="POST" action="/dash/config">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="excluded_countries">Excluded Countries</label>
|
||||||
|
<input type="text" class="form-control" id="excluded_countries" name="excluded_countries" value="{{ excluded_countries }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="preferred_protocols">Preferred Protocols</label>
|
||||||
|
<input type="text" class="form-control" id="preferred_protocols" name="preferred_protocols" value="{{ preferred_protocols }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="preferred_types">Preferred Types</label>
|
||||||
|
<input type="text" class="form-control" id="preferred_types" name="preferred_types" value="{{ preferred_types }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="min_preference">Minimum Preference</label>
|
||||||
|
<input type="text" class="form-control" id="min_preference" name="min_preference" value="{{ min_preference }}">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
8
templates/logs.html
Normal file
8
templates/logs.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="tab-pane fade show active">
|
||||||
|
<h2>Error Logs</h2>
|
||||||
|
<p>Error logs content goes here.</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
8
templates/stats.html
Normal file
8
templates/stats.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="tab-pane fade show active">
|
||||||
|
<h2>Statistics</h2>
|
||||||
|
<p>Statistics content goes here.</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user