-
-
Save generalistcodes/19eb6d66985b1ff44d2d4c82cf53c82b to your computer and use it in GitHub Desktop.
Revisions
-
jeremyjordan renamed this gist
Oct 27, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jeremyjordan renamed this gist
Oct 27, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jeremyjordan revised this gist
Oct 27, 2019 . No changes.There are no files selected for viewing
-
jeremyjordan created this gist
Oct 27, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ Example for discussion: https://discuss.streamlit.io/t/how-to-evolve-complex-state-e-g-annotate-data/ Install the requirements. ``` fastapi==0.42.0 streamlit==0.49.0 uvicorn==0.9.1 ``` Run the server. ``` uvicorn server:app --reload ``` Run Streamlit. ``` streamlit run letters.py ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import streamlit as st import requests st.subheader('existing letters') letters = requests.get('http://127.0.0.1:8000/letters').json() for letter in letters: st.write(letter) st.subheader('add new letters') new_candidates = [] for new_letter in ['d', 'e', 'f']: st.write(f'add {new_letter}') add_letter = st.checkbox(f'add {new_letter}') if add_letter: new_candidates.append(new_letter) submit = st.button('submit new letters') if submit: requests.post('http://127.0.0.1:8000/letters', json=new_candidates) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ from fastapi import FastAPI from typing import List app = FastAPI() LETTERS = [] @app.get("/letters") def list_letters(): return LETTERS @app.post("/letters") def add_letters(letters: List[str]): LETTERS.extend(letters) return {'added': len(letters)}