File size: 1,103 Bytes
d2ed9d5
 
3fdffaf
d2ed9d5
3fdffaf
d2ed9d5
3fdffaf
 
d2ed9d5
 
 
 
 
 
 
 
 
 
 
 
 
3fdffaf
d2ed9d5
8b3247e
 
d2ed9d5
 
3fdffaf
 
d2ed9d5
 
 
 
 
 
 
 
3fdffaf
e9f8276
3fdffaf
d2ed9d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from shiny import App, ui, render, reactive
import requests

# Define the UI layout
app_ui = ui.page_fluid(
    ui.panel_title("Shiny App with Google OAuth"),
    ui.layout_sidebar(
        ui.sidebar(
            ui.markdown(
                """
                ## Authentication Required
                Please authenticate via Google to access the full features of this app.
                
                [Click here to log in](http://localhost:5001/login)
                
                After successful authentication, refresh this page.
                """
            ),
        ),
        ui.main_panel(
            ui.output_text("user_info"),
        ),
    ),
)

# Define the server logic
def server(input, output, session):
    @output
    @render.text
    def user_info():
        user_data = requests.get("http://flask_app:5001/user_info").json()
        if user_data:
            return f"Welcome, {user_data.get('name')}!"
        else:
            return "User not authenticated."

# Create the Shiny app
app = App(app_ui, server)

if __name__ == "__main__":
    app.run(port=7860)