GithubHelp home page GithubHelp logo

blackary / notionlit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tvst/notionlit

0.0 0.0 0.0 18 KB

Write Streamlit apps using Notion! (Prototype)

License: Apache License 2.0

Python 100.00%

notionlit's Introduction

Streamlit + Notion test app

Write Streamlit apps using Notion!

โ˜ ๏ธ IMPORTANT: This is just a little prototype I made to play with some ideas. Not meant for production!

Forking instructions

  1. Fork this app into your own repo (or just copy streamlit_app.py. It's fully self-contained!)

  2. Create a new integration in Notion. When you're done, grab the secret token as you'll need it later.

  3. Create a page in Notion, then:

    1. Share it with your integration
    2. Grab the page URL as you'llneed it later.
  4. Deploy your app with share.streamlit.io.

  5. Set up your app's secrets, adding in the secret token and page URL from the steps above.

    [notion]
    token = "YOUR_NOTION_SECRET"
    page_url = "YOUR_NOTION_PAGE_URL"
    

๐Ÿฅณ Done!

Now any time you edit your Notion page, go into your Streamlit app and press R to rerun it (thereby fetching the latest content from Notion).

But wait, there's more!

If you add a code block in Notion and mark it as a Python block, it will actually get executed when you load your app!

So try adding a Python block with this into your Notion page:

import streamlit as st
import numpy as np

num_rows = st.slider("Number of rows", 1, 500, 100)
data = np.random.randn(num_rows, 5)

st.write(data)
st.line_chart(data)

(If you need other Python packages, add them to your requirements.txt)

One more thing: let's say you want to execute Python code, but don't want to pollute your Notion page with too much ugly code. There's a hack for that. Just put the code inside an expander without a title or with a title equal to "Code".

What's supported

  • Headers
  • Paragraphs (with bold/italic/strikethrough/links)
  • Images
  • Code blocks
  • Expanders
  • @user_mentions
  • @date_mentions

And that's all โ˜น๏ธ

Again, this is just a proof-of-concept / prototype. So I didn't implement a bunch of other stuff, like underline, @page_mentions, columns, etc.

Also note that not everything in Streamlit is supported either. I don't have an exhaustive list but, for example, magic doesn't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.