Spaces:
Runtime error
Runtime error
Commit
·
50b32a4
0
Parent(s):
:tada: init
Browse files- .gitattributes +27 -0
- .github/workflows/check_size.yaml +17 -0
- .github/workflows/sync_to_hub.yaml +20 -0
- README.md +19 -0
- app.py +64 -0
- images/huggingface_logo.png +0 -0
- packages.txt +0 -0
- posts/check_this_out.md +10 -0
- posts/hello_world.md +10 -0
- requirements.txt +1 -0
.gitattributes
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/check_size.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Check file size
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
branches: [main]
|
| 6 |
+
|
| 7 |
+
# to run this workflow manually from the Actions tab
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
sync-to-hub:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Check large files
|
| 15 |
+
uses: ActionsDesk/[email protected]
|
| 16 |
+
with:
|
| 17 |
+
filesizelimit: 10485760 # = 10MB, so we can sync to HF spaces
|
.github/workflows/sync_to_hub.yaml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
|
| 7 |
+
# to run this workflow manually from the Actions tab
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
sync-to-hub:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- uses: actions/checkout@v2
|
| 15 |
+
with:
|
| 16 |
+
fetch-depth: 0
|
| 17 |
+
- name: Push to hub
|
| 18 |
+
env:
|
| 19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push https://nateraw:[email protected]/spaces/nateraw/host-a-blog-on-huggingface-spaces main --force
|
README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Host a Blog on HuggingFace Spaces
|
| 3 |
+
emoji: 🤗
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Host a Blog on HuggingFace Spaces
|
| 12 |
+
|
| 13 |
+
[](https://huggingface.co/spaces/nateraw/host-a-blog-on-huggingface-spaces)
|
| 14 |
+
|
| 15 |
+
How to host a blog on 🤗
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
Autogenerated using [this template](https://github.com/nateraw/spaces-template)
|
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import re
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import yaml
|
| 6 |
+
|
| 7 |
+
REGEX_YAML_BLOCK = re.compile(r"---[\n\r]+([\S\s]*?)[\n\r]+---[\n\r](.*)", re.DOTALL)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def render_preview(image, title, description):
|
| 11 |
+
with st.container():
|
| 12 |
+
image_col, text_col = st.columns((1,2))
|
| 13 |
+
with image_col:
|
| 14 |
+
st.image(image)
|
| 15 |
+
|
| 16 |
+
with text_col:
|
| 17 |
+
st.subheader(title)
|
| 18 |
+
st.write(description)
|
| 19 |
+
clicked = st.button("Read more...", key=title)
|
| 20 |
+
return clicked
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def render_page(post_path: Path):
|
| 24 |
+
text = post_path.read_text()
|
| 25 |
+
match = REGEX_YAML_BLOCK.search(text)
|
| 26 |
+
page_content = match.group(2) if match else text
|
| 27 |
+
st.markdown(page_content, unsafe_allow_html=True)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def get_page_data(post_path: Path):
|
| 31 |
+
text = post_path.read_text()
|
| 32 |
+
match = REGEX_YAML_BLOCK.search(text)
|
| 33 |
+
if match:
|
| 34 |
+
data = match.group(1)
|
| 35 |
+
data = yaml.load(data, Loader=yaml.FullLoader)
|
| 36 |
+
return data
|
| 37 |
+
return {}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def main():
|
| 41 |
+
st.set_page_config(layout="wide")
|
| 42 |
+
posts = ['posts/hello_world.md', 'posts/check_this_out.md']
|
| 43 |
+
page_to_show = None
|
| 44 |
+
with st.sidebar:
|
| 45 |
+
|
| 46 |
+
st.markdown('''
|
| 47 |
+
<div align="center">
|
| 48 |
+
<h1>A Test Blog!</h1>
|
| 49 |
+
|
| 50 |
+
[](https://github.com/nateraw/host-a-blog-on-huggingface-spaces)
|
| 51 |
+
</div>
|
| 52 |
+
''', unsafe_allow_html=True)
|
| 53 |
+
st.markdown('---')
|
| 54 |
+
|
| 55 |
+
for post in posts:
|
| 56 |
+
data = get_page_data(Path(post))
|
| 57 |
+
clicked = render_preview(data.get("thumbnail"), data.get("title"), data.get("description"))
|
| 58 |
+
if clicked:
|
| 59 |
+
page_to_show = post
|
| 60 |
+
|
| 61 |
+
if page_to_show:
|
| 62 |
+
render_page(Path(page_to_show))
|
| 63 |
+
|
| 64 |
+
main()
|
images/huggingface_logo.png
ADDED
|
packages.txt
ADDED
|
File without changes
|
posts/check_this_out.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: A new release of blah blah
|
| 3 |
+
description: Hopefully this can be really cool one day
|
| 4 |
+
date: 2020-01-02
|
| 5 |
+
thumbnail: images/huggingface_logo.png
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Some cool title
|
| 9 |
+
|
| 10 |
+
asdfasdf
|
posts/hello_world.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Hello World
|
| 3 |
+
description: This is my first blogpost
|
| 4 |
+
date: 2020-01-01
|
| 5 |
+
thumbnail: images/huggingface_logo.png
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Hello world!
|
| 9 |
+
|
| 10 |
+
Welcome to my first blogpost!
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
streamlit
|