Compare commits
No commits in common. "2f5f364cdeebd6bfe9c74d258a7dfb674457e992" and "ff5b8b4937999d016cdca7f0f60d01d02a1f2fa1" have entirely different histories.
2f5f364cde
...
ff5b8b4937
@ -1,9 +0,0 @@
|
|||||||
.git
|
|
||||||
.gitignore
|
|
||||||
.dockerignore
|
|
||||||
.env
|
|
||||||
poetry.lock
|
|
||||||
poetry.toml
|
|
||||||
pyproject.toml
|
|
||||||
README.md
|
|
||||||
tests/
|
|
@ -1,45 +0,0 @@
|
|||||||
name: Build and Publish Docker Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*.*.*"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ secrets.REGISTRY }}/${{ secrets.USERNAME }}/ktvmanager-backend-python
|
|
||||||
tags: |
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to Docker Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ secrets.REGISTRY }}
|
|
||||||
username: ${{ secrets.USERNAME }}
|
|
||||||
password: ${{ secrets.PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: |
|
|
||||||
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
|
|
||||||
org.opencontainers.image.title=ktvmanager-backend-python
|
|
||||||
org.opencontainers.image.description=ktvmanager-backend-python
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ steps.meta.outputs.version }}
|
|
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@ -7,16 +7,19 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "flask",
|
"module": "flask",
|
||||||
"env": {
|
"env": {
|
||||||
"FLASK_APP": "ktvmanager.main:create_app",
|
"FLASK_APP": "ktvmanager.main:create_app()",
|
||||||
"FLASK_ENV": "development",
|
"FLASK_DEBUG": "1"
|
||||||
"PYTHONPATH": "${workspaceFolder}",
|
|
||||||
"FLASK_RUN_PORT": "5001"
|
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"run",
|
"run",
|
||||||
"--host=0.0.0.0"
|
"--no-debugger",
|
||||||
|
"--no-reload",
|
||||||
|
"--host=0.0.0.0",
|
||||||
|
"--port=5001"
|
||||||
],
|
],
|
||||||
"jinja": false
|
"jinja": true,
|
||||||
|
"justMyCode": true,
|
||||||
|
"python": "${workspaceFolder}/.venv/bin/python"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
# config.py.sample
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
DEBUG = False
|
|
||||||
SECRET_KEY = 'a_secret_key'
|
|
||||||
|
|
||||||
class DevelopmentConfig(Config):
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
class ProductionConfig(Config):
|
|
||||||
pass
|
|
31
dockerfile
31
dockerfile
@ -1,31 +0,0 @@
|
|||||||
FROM python:3.11-slim-bookworm
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
git \
|
|
||||||
libglib2.0-0 \
|
|
||||||
libsm6 \
|
|
||||||
libxrender1 \
|
|
||||||
libxext6 \
|
|
||||||
libgomp1 \
|
|
||||||
libgl1 \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY requirements.txt .
|
|
||||||
RUN pip install --no-cache-dir requests stem
|
|
||||||
RUN pip install --no-cache-dir git+https://github.com/karl0ss/requests_tor.git@ae1e85abb3bb2c25f431bd031c6d881986c626f6
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN chmod +x run.sh
|
|
||||||
|
|
||||||
ARG VERSION
|
|
||||||
RUN echo $VERSION > VERSION
|
|
||||||
|
|
||||||
EXPOSE 3001
|
|
||||||
|
|
||||||
ENV FLASK_ENV=production
|
|
||||||
CMD ["./run.sh"]
|
|
@ -1,22 +0,0 @@
|
|||||||
# ktvmanager/config.py
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
DEBUG = False
|
|
||||||
TESTING = False
|
|
||||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'my_secret_key')
|
|
||||||
HOST = '0.0.0.0'
|
|
||||||
PORT = 3001
|
|
||||||
DBHOST = os.getenv("DBHOST")
|
|
||||||
DBUSER = os.getenv("DBUSER")
|
|
||||||
DBPASS = os.getenv("DBPASS")
|
|
||||||
DATABASE = os.getenv("DATABASE")
|
|
||||||
DBPORT = os.getenv("DBPORT")
|
|
||||||
STREAM_URLS = ["http://example.com", "http://example.org"]
|
|
||||||
|
|
||||||
class DevelopmentConfig(Config):
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
class ProductionConfig(Config):
|
|
||||||
PORT = os.environ.get('PORT', 5000)
|
|
@ -1,15 +1,19 @@
|
|||||||
|
import os
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
from flask import jsonify, request, current_app
|
from dotenv import load_dotenv
|
||||||
|
from flask import jsonify, request
|
||||||
from ktvmanager.lib.checker import single_account_check
|
from ktvmanager.lib.checker import single_account_check
|
||||||
from ktvmanager.lib.encryption import encrypt_password, decrypt_password
|
from ktvmanager.lib.encryption import encrypt_password, decrypt_password
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
def _create_connection():
|
def _create_connection():
|
||||||
return mysql.connector.connect(
|
return mysql.connector.connect(
|
||||||
host=current_app.config["DBHOST"],
|
host=os.getenv("DBHOST"),
|
||||||
user=current_app.config["DBUSER"],
|
user=os.getenv("DBUSER"),
|
||||||
password=current_app.config["DBPASS"],
|
password=os.getenv("DBPASS"),
|
||||||
database=current_app.config["DATABASE"],
|
database=os.getenv("DATABASE"),
|
||||||
port=current_app.config["DBPORT"]
|
port=os.getenv("DBPORT")
|
||||||
)
|
)
|
||||||
|
|
||||||
def _execute_query(query, params=None):
|
def _execute_query(query, params=None):
|
||||||
@ -54,7 +58,9 @@ def get_stream_names():
|
|||||||
|
|
||||||
def single_check():
|
def single_check():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
stream_urls = current_app.config["STREAM_URLS"]
|
# This is a placeholder for getting stream URLs. In a real application,
|
||||||
|
# this would likely come from a database query or a configuration file.
|
||||||
|
stream_urls = ["http://example.com", "http://example.org"]
|
||||||
result = single_account_check(data, stream_urls)
|
result = single_account_check(data, stream_urls)
|
||||||
if result:
|
if result:
|
||||||
# Here you would typically update the database with the new information
|
# Here you would typically update the database with the new information
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
import os
|
|
||||||
from flask import Flask, jsonify
|
from flask import Flask, jsonify
|
||||||
from dotenv import load_dotenv
|
|
||||||
from ktvmanager.config import DevelopmentConfig, ProductionConfig
|
|
||||||
from routes.api import api_blueprint
|
from routes.api import api_blueprint
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
if os.environ.get("FLASK_ENV") == "production":
|
|
||||||
app.config.from_object(ProductionConfig)
|
|
||||||
else:
|
|
||||||
app.config.from_object(DevelopmentConfig)
|
|
||||||
|
|
||||||
# Register blueprints
|
# Register blueprints
|
||||||
app.register_blueprint(api_blueprint)
|
app.register_blueprint(api_blueprint)
|
||||||
@ -29,4 +20,4 @@ def create_app():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = create_app()
|
app = create_app()
|
||||||
app.run(debug=app.config["DEBUG"], host=app.config["HOST"], port=app.config["PORT"])
|
app.run(debug=True, host='0.0.0.0', port=5001)
|
Loading…
x
Reference in New Issue
Block a user