Made api async #70
This commit is contained in:
parent
aab3d62365
commit
e8c491a478
@ -47,6 +47,7 @@ class Application(DiscordBotApplicationABC):
|
|||||||
self._api.start()
|
self._api.start()
|
||||||
|
|
||||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_only):
|
if self._feature_flags.get_flag(FeatureFlagsEnum.api_only):
|
||||||
|
self._api.join()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
||||||
|
@ -14,7 +14,7 @@ class ApiThread(threading.Thread):
|
|||||||
api: Api,
|
api: Api,
|
||||||
feature_flags: FeatureFlagsSettings
|
feature_flags: FeatureFlagsSettings
|
||||||
):
|
):
|
||||||
threading.Thread.__init__(self, daemon=not feature_flags.get_flag(FeatureFlagsEnum.api_only))
|
threading.Thread.__init__(self, daemon=True)
|
||||||
|
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._api = api
|
self._api = api
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
"LicenseDescription": "",
|
"LicenseDescription": "",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core==2022.10.0.post6",
|
"cpl-core==2022.10.0.post6",
|
||||||
"Flask==2.2.2",
|
"Flask[async]==2.2.2",
|
||||||
"Flask-Classful==0.14.2"
|
"Flask-Classful==0.14.2"
|
||||||
],
|
],
|
||||||
"DevDependencies": [
|
"DevDependencies": [
|
||||||
|
@ -33,13 +33,13 @@ class ApiController:
|
|||||||
self._mailer = mailer
|
self._mailer = mailer
|
||||||
|
|
||||||
@Route.route('/api/api-version')
|
@Route.route('/api/api-version')
|
||||||
def api_version(self):
|
async def api_version(self):
|
||||||
import bot_api
|
import bot_api
|
||||||
version = bot_api.version_info
|
version = bot_api.version_info
|
||||||
return VersionDTO(version.major, version.minor, version.micro).to_dict()
|
return VersionDTO(version.major, version.minor, version.micro).to_dict()
|
||||||
|
|
||||||
@Route.route('/api/settings')
|
@Route.route('/api/settings')
|
||||||
def settings(self):
|
async def settings(self):
|
||||||
# TODO: Authentication
|
# TODO: Authentication
|
||||||
import bot_api
|
import bot_api
|
||||||
version = bot_api.version_info
|
version = bot_api.version_info
|
||||||
@ -60,7 +60,7 @@ class ApiController:
|
|||||||
).to_dict()
|
).to_dict()
|
||||||
|
|
||||||
@Route.route('/api/send-test-mail/<email>')
|
@Route.route('/api/send-test-mail/<email>')
|
||||||
def send_test_mail(self, email: str):
|
async def send_test_mail(self, email: str):
|
||||||
# TODO: Authentication
|
# TODO: Authentication
|
||||||
mail = EMail()
|
mail = EMail()
|
||||||
mail.add_header('Mime-Version: 1.0')
|
mail.add_header('Mime-Version: 1.0')
|
||||||
|
Loading…
Reference in New Issue
Block a user