move glob and utils
This commit is contained in:
18
app/glob.py
Normal file
18
app/glob.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from flask import g
|
||||
|
||||
from app.config import load_config, config_location
|
||||
from app.manager import PublicationManager
|
||||
|
||||
|
||||
def get_config():
|
||||
if 'config' not in g:
|
||||
g.config = load_config(config_location())
|
||||
|
||||
return g.config
|
||||
|
||||
|
||||
def get_manager():
|
||||
if 'manager' not in g:
|
||||
g.manager = PublicationManager(get_config())
|
||||
|
||||
return g.manager
|
10
app/utils.py
Normal file
10
app/utils.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from flask_restful import abort
|
||||
from pathvalidate import is_valid_filepath
|
||||
|
||||
|
||||
def validate_url(url: Optional[str]):
|
||||
if url is not None:
|
||||
if not is_valid_filepath(url, platform='posix'):
|
||||
abort(400, message='invalid url')
|
Reference in New Issue
Block a user