This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot / Dataframe | |
# Examples of how to format pandas data when plotting | |
# Use the `tolist()` function on `df.columns` and `df.values` along with Wave's `data` class | |
# --- | |
from h2o_wave import site, data, ui, main | |
import pandas as pd | |
import numpy as np | |
# Page to hold our charts | |
page = site['/demo'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from h2o_wave import main, app, Q, ui, data | |
import pandas as pd | |
import numpy as np | |
@app('/') | |
async def serve(q: Q): | |
print(q.args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, Q, ui, handle_on, on, data | |
from loguru import logger | |
def on_startup(): | |
""" | |
Runs when the app is started, even if there are no browsers connected | |
:return: | |
""" | |
logger.info('http://localhost:10101/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, Q, ui, on, handle_on | |
@app('/') | |
async def serve(q: Q): | |
if not q.client.initialized: # first time a tab comes this is app | |
q.page['a'] = ui.form_card( | |
box='4 3 4 2', | |
items=[ | |
ui.textbox(name='color_textbox', placeholder='Purple'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, site, Q, ui | |
def create_stat_card(name: str, n: int): | |
page[name] = ui.tall_gauge_stat_card( | |
box=ui.box(zone='body', width='200px', height='200px'), | |
title='test '*n, | |
value=str(n), | |
aux_value=str(n*100), | |
progress=n*0.1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from h2o_wave import main, app, Q, ui, on, handle_on | |
from loguru import logger | |
def on_startup(): | |
logger.info('http://localhost:10101') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
from h2o_wave import main, app, Q, ui | |
def sleeper_agent(secs) -> str: | |
time.sleep(secs) # Blocks! | |
return f'Done waiting for {secs} seconds!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from apscheduler.schedulers.asyncio import AsyncIOScheduler | |
from h2o_wave import main, app, Q, ui, handle_on, on, data | |
SCHEDULER = AsyncIOScheduler() | |
@app('/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, ui, Q, on, handle_on, data | |
from pandas_datareader import data as web | |
import pandas as pd | |
from datetime import datetime as dt | |
@app("/") | |
async def serve(q: Q): | |
stock = q.args["my-dropdown"] or "COKE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import numpy as np | |
import pandas as pd | |
import requests | |
""" | |
Suggestions on how to use this in an H2O Wave app: | |
1. Have a page with a textbox asking users for a URL of a REST endpoint | |
2. Allow users to upload a CSV with new data |
OlderNewer