FabienArcellier / writer-framework

No-code in the front, Python in the back. An open-source framework for creating data apps.
https://streamsync.cloud
Apache License 2.0
0 stars 1 forks source link

In-app route definition for authentication callback #56

Closed FabienArcellier closed 4 months ago

FabienArcellier commented 4 months ago

Modifying the fastapi router is complex to carry out from a streamsync application because it is isolated in a subprocess. The streamsync application sees a copy of the fastapi object. Changes are not taken into account.

image


import streamsync as ss

@ss.serve.get('/auth/callback')
def route(state, context):
  state['username'] = 'fabien'

Using redirection

import streamsync as ss

@ss.serve.get('/auth/callback')
def route(state, context):
  state['username'] = 'fabien'
  state.open_url('http://www.google.fr')

Using context

import streamsync as ss

@ss.serve.get('/auth/callback')
def route(state, context):
  request = context.request
  state['username'] = 'fabien'
  state.open_url('http://www.google.fr')