Added flask support #70 #75 #71

Merged
edraft merged 107 commits from #70 into 0.3 2022-11-05 13:55:42 +01:00
4 changed files with 6 additions and 5 deletions
Showing only changes of commit e8c491a478 - Show all commits

View File

@ -47,6 +47,7 @@ class Application(DiscordBotApplicationABC):
self._api.start()
if self._feature_flags.get_flag(FeatureFlagsEnum.api_only):
self._api.join()
return
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')

View File

@ -14,7 +14,7 @@ class ApiThread(threading.Thread):
api: Api,
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._api = api

View File

@ -17,7 +17,7 @@
"LicenseDescription": "",
"Dependencies": [
"cpl-core==2022.10.0.post6",
"Flask==2.2.2",
"Flask[async]==2.2.2",
"Flask-Classful==0.14.2"
],
"DevDependencies": [

View File

@ -33,13 +33,13 @@ class ApiController:
self._mailer = mailer
@Route.route('/api/api-version')
def api_version(self):
async def api_version(self):
import bot_api
version = bot_api.version_info
return VersionDTO(version.major, version.minor, version.micro).to_dict()
@Route.route('/api/settings')
def settings(self):
async def settings(self):
# TODO: Authentication
import bot_api
version = bot_api.version_info
@ -60,7 +60,7 @@ class ApiController:
).to_dict()
@Route.route('/api/send-test-mail/<email>')
def send_test_mail(self, email: str):
async def send_test_mail(self, email: str):
# TODO: Authentication
mail = EMail()
mail.add_header('Mime-Version: 1.0')