mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
[-] Optimized error handling & imports
[~] Reordered functions
This commit is contained in:
parent
315acec4a2
commit
a5ab9a0caa
11
app.py
11
app.py
@ -3,7 +3,6 @@ import atexit
|
|||||||
import http
|
import http
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
from mailbox import FormatError
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
@ -18,7 +17,7 @@ import firebase_manager
|
|||||||
import generic_executor
|
import generic_executor
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000 * 1000
|
app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000 * 1000 #15.28MB~
|
||||||
cors = CORS(app, origins="*")
|
cors = CORS(app, origins="*")
|
||||||
apiBP = Blueprint('apiBP', 'BPapi')
|
apiBP = Blueprint('apiBP', 'BPapi')
|
||||||
|
|
||||||
@ -94,9 +93,9 @@ route_handlers = {
|
|||||||
'FetchHistory': generic_executor.fetch_history,
|
'FetchHistory': generic_executor.fetch_history,
|
||||||
'FetchPlayersStatus': generic_executor.fetch_players_status,
|
'FetchPlayersStatus': generic_executor.fetch_players_status,
|
||||||
'AccountCreate': generic_executor.account_create,
|
'AccountCreate': generic_executor.account_create,
|
||||||
|
'AccountDelete': generic_executor.account_delete,
|
||||||
'ServerCreate': generic_executor.server_create,
|
'ServerCreate': generic_executor.server_create,
|
||||||
'ServerDelete': generic_executor.server_delete,
|
'ServerDelete': generic_executor.server_delete,
|
||||||
'AccountDelete': generic_executor.account_delete,
|
|
||||||
'ServerRun': generic_executor.server_run,
|
'ServerRun': generic_executor.server_run,
|
||||||
'ServerStop': generic_executor.server_stop,
|
'ServerStop': generic_executor.server_stop,
|
||||||
'UpdateProperties': generic_executor.update_properties,
|
'UpdateProperties': generic_executor.update_properties,
|
||||||
@ -136,9 +135,9 @@ def upload():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if not form:
|
if not form:
|
||||||
raise FormatError(0)
|
raise SyntaxError(0)
|
||||||
if not files:
|
if not files:
|
||||||
raise FormatError(1)
|
raise SyntaxError(1)
|
||||||
if not token:
|
if not token:
|
||||||
raise KeyError('token')
|
raise KeyError('token')
|
||||||
if not name:
|
if not name:
|
||||||
@ -156,7 +155,7 @@ def upload():
|
|||||||
filename = secure_filename(filename)
|
filename = secure_filename(filename)
|
||||||
file.save(os.path.join(f"users/{user_id}/{name}/{internal_path}", filename))
|
file.save(os.path.join(f"users/{user_id}/{name}/{internal_path}", filename))
|
||||||
|
|
||||||
except FormatError as e:
|
except SyntaxError as e:
|
||||||
match e:
|
match e:
|
||||||
case 0:
|
case 0:
|
||||||
return generic_response_maker(http.HTTPStatus.BAD_REQUEST, "No FormData found in the payload.")
|
return generic_response_maker(http.HTTPStatus.BAD_REQUEST, "No FormData found in the payload.")
|
||||||
|
Loading…
Reference in New Issue
Block a user