From d56cbea6977364da7df0d088a50b6b0f2ed1f038 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 27 Oct 2022 16:19:11 +0200 Subject: [PATCH] add types --- src/app.py | 3 ++- src/config.py | 2 +- src/routes/api/download.py | 5 +++-- src/routes/api/upload.py | 3 ++- src/routes/index.py | 4 ++-- src/utils/font.py | 2 +- src/utils/libjs.py | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app.py b/src/app.py index 7c939e8..2734b06 100644 --- a/src/app.py +++ b/src/app.py @@ -1,4 +1,5 @@ from flask import Flask, redirect +from werkzeug.wrappers.response import Response from config import init from routes.api.download import router as api_download @@ -14,5 +15,5 @@ init() @app.route("/") -def root(): +def root() -> Response: return redirect("index") diff --git a/src/config.py b/src/config.py index adae529..94190ad 100644 --- a/src/config.py +++ b/src/config.py @@ -10,7 +10,7 @@ class Config: uploads_dir = "uploads" -def init(): +def init() -> None: # Download dependencies init_font("1.3.0") init_libjs("fc5e3c53e41490e24ca7f67cb24e7ab389b770f9") diff --git a/src/routes/api/download.py b/src/routes/api/download.py index 816f7c2..33cf14a 100644 --- a/src/routes/api/download.py +++ b/src/routes/api/download.py @@ -1,8 +1,9 @@ -from flask import Blueprint, redirect, request +from flask import Blueprint, redirect +from werkzeug.wrappers.response import Response router = Blueprint("download", __name__) @router.route("", methods=["POST"]) -def download(): +def download() -> Response: return redirect("index") diff --git a/src/routes/api/upload.py b/src/routes/api/upload.py index a1dbdca..de4cc67 100644 --- a/src/routes/api/upload.py +++ b/src/routes/api/upload.py @@ -1,12 +1,13 @@ from config import Config from flask import Blueprint, redirect, request from utils.misc import h +from werkzeug.wrappers.response import Response router = Blueprint("upload", __name__) @router.route("", methods=["POST"]) -def upload(): +def upload() -> Response: if request.method == "POST": json = request.get_json() if json: diff --git a/src/routes/index.py b/src/routes/index.py index 5883953..eaac193 100644 --- a/src/routes/index.py +++ b/src/routes/index.py @@ -1,9 +1,9 @@ -from flask import Blueprint, render_template from config import Config +from flask import Blueprint, render_template router = Blueprint("index", __name__) @router.route("") -def index(): +def index() -> str: return render_template("index.html", name=Config.name) diff --git a/src/utils/font.py b/src/utils/font.py index 74929bf..f1b73f6 100644 --- a/src/utils/font.py +++ b/src/utils/font.py @@ -5,7 +5,7 @@ from requests import get from utils.misc import exist -def init(version): +def init(version: str) -> None: """ Download font """ path = "./src/public/fonts" filename = "RiluRegular.ttf" diff --git a/src/utils/libjs.py b/src/utils/libjs.py index 7ee2507..21ee552 100644 --- a/src/utils/libjs.py +++ b/src/utils/libjs.py @@ -5,7 +5,7 @@ from requests import get from utils.misc import exist -def init(commit_hash): +def init(commit_hash: str) -> None: """ Download JS libraries""" path = "./src/public/js/libs" filename = "bigint-mod.js"