Switched API

This commit is contained in:
Firq 2024-10-04 00:31:31 +02:00
parent 27fd95ba1e
commit 0373ec7625
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
6 changed files with 21 additions and 6 deletions

View file

@ -1,8 +1,6 @@
on:
push:
tags:
- '[0-9]+\.[0-9]+\.[0-9]+-c\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+-a\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]'
jobs:
@ -55,7 +53,7 @@ jobs:
build-args: |
PACKAGE_VERSION=${{ github.ref_name }}
push: true
tags: forgejo.neshweb.net/firq/support-formatter:${{ github.ref_name }}
tags: forgejo.neshweb.net/firq/support-formatter:${{ github.ref_name }}, forgejo.neshweb.net/firq/support-formatter:latest
release:
needs: [ build-and-push-container, publish-artifacts ]

View file

@ -1,6 +1,6 @@
[project]
name = "support_formatter"
version = "0.1.0"
version = "0.2.0"
requires-python = ">= 3.10"
authors = [{name = "Firq", email = "firelp42@gmail.com"}]
maintainers = [{name = "Firq", email = "firelp42@gmail.com"}]

View file

@ -33,3 +33,5 @@ class APISettings:
ALLOWED_EXTENSIONS = { 'csv', 'txt' }
FILE_SAVE_DIRECTORY = Path(__file__).parents[1] / ".temp"
UI_URL = "https://support-formatter.firq.dev/"

View file

@ -1,7 +1,8 @@
# pylint: disable=wrong-import-position,cyclic-import
from flask_smorest import Blueprint
redirect_routes = Blueprint("redirect", "recirects", url_prefix="/", description="")
interface_routes = Blueprint("interface", "interface", url_prefix="/", description="")
formatter_routes = Blueprint("formatter", "formatter", url_prefix="/", description="")
from . import interface, upload # avoids circular imports problem
from . import interface, upload, redirects # avoids circular imports problem

View file

@ -0,0 +1,12 @@
from flask import redirect
from ..app import Application
from ..config import APISettings
from . import redirect_routes as blp
APP = Application.get_instance()
@blp.route("/", methods=["GET"])
@blp.doc(summary="This route just exists to redirect any visitor to the root domain to the UI")
def redirect_to_ui():
return redirect(APISettings.UI_URL)

View file

@ -3,13 +3,15 @@ from gevent.monkey import patch_all; patch_all()
from gevent.pywsgi import WSGIServer
from .app import Application
from .routes import interface_routes, formatter_routes
from .routes import interface_routes, formatter_routes, redirect_routes
from .config import APISettings, ServerSettings
APISettings.FILE_SAVE_DIRECTORY.mkdir(parents=True, exist_ok=True)
APP = Application.get_instance()
app, api = APP.app, APP.api
api.register_blueprint(redirect_routes)
api.register_blueprint(interface_routes)
api.register_blueprint(formatter_routes)