mirror of
https://github.com/norohind/FDEV-CAPI-Handler.git
synced 2026-10-25 01:06:03 +03:00
WIP: full refactor
This commit is contained in:
11 files changed
+904
-2
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import falcon
|
||||
import waitress
|
||||
import json
|
||||
|
||||
from capi import capi_authorizer
|
||||
import config
|
||||
|
||||
|
||||
class AuthInit:
|
||||
def on_get(self, req: falcon.request.Request, resp: falcon.response.Response) -> None:
|
||||
resp.content_type = falcon.MEDIA_HTML
|
||||
resp.text = config.REDIRECT_HTML_TEMPLATE.format(link=capi_authorizer.auth_init())
|
||||
|
||||
|
||||
class FDEVCallback:
|
||||
def on_get(self, req: falcon.request.Request, resp: falcon.response.Response) -> None:
|
||||
code = req.get_param('code')
|
||||
state = req.get_param('state')
|
||||
msg = capi_authorizer.fdev_callback(code, state)
|
||||
resp.content_type = falcon.MEDIA_JSON
|
||||
resp.text = json.dumps(msg)
|
||||
|
||||
|
||||
application = falcon.App()
|
||||
application.add_route('/authorize', AuthInit())
|
||||
application.add_route('/fdev-redirect', FDEVCallback())
|
||||
|
||||
if __name__ == '__main__':
|
||||
waitress.serve(application, host='127.0.0.1', port=9000)
|
||||
Reference in new issue
Block a user