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): | |
print(q.args) | |
# First time a browser comes to the app | |
if not q.client.initialized: | |
await init(q) |
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 requests | |
from h2o_wave import main, app, Q, ui, expando_to_dict | |
ENDPOINT = "https://model.DOMAIN.h2o.ai/MODELID/model" | |
APP_TITLE = "My Use Case" | |
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
""" | |
Demo of Updating App Data in one card of an app | |
""" | |
from random import randint | |
from h2o_wave import Q, app, handle_on, main, on, ui | |
@app("/") | |
async def serve(q: Q): |
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 | |
import pandas as pd | |
import numpy as np | |
@app('/') | |
async def serve(q: Q): | |
print(q.args) | |
if not q.client.initialized: |
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 |
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 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
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
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
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, |