Spaces:
Running
Running
osanseviero
commited on
Commit
β’
0be042f
1
Parent(s):
147d46a
Initial test
Browse files- README.md +1 -1
- app.py +5 -4
- images/huggingface_logo.png β assets/1_huggingface_logo.png +0 -0
- assets/1_streamlit_space.png +0 -0
- posts/1_blog_in_spaces.md +46 -0
- posts/check_this_out.md +0 -10
- posts/hello_world.md +0 -10
- requirements.txt +1 -0
README.md
CHANGED
@@ -10,7 +10,7 @@ pinned: false
|
|
10 |
|
11 |
# Host a Blog on HuggingFace Spaces
|
12 |
|
13 |
-
[![Generic badge](https://img.shields.io/badge/π€-Open%20In%20Spaces-blue.svg)](https://huggingface.co/spaces/
|
14 |
|
15 |
How to host a blog on π€
|
16 |
|
|
|
10 |
|
11 |
# Host a Blog on HuggingFace Spaces
|
12 |
|
13 |
+
[![Generic badge](https://img.shields.io/badge/π€-Open%20In%20Spaces-blue.svg)](https://huggingface.co/spaces/osanseviero/tips-and-tricks)
|
14 |
|
15 |
How to host a blog on π€
|
16 |
|
app.py
CHANGED
@@ -39,15 +39,16 @@ def get_page_data(post_path: Path):
|
|
39 |
|
40 |
def main():
|
41 |
st.set_page_config(layout="wide")
|
42 |
-
posts = ['posts/
|
43 |
-
page_to_show =
|
44 |
with st.sidebar:
|
45 |
|
46 |
st.markdown('''
|
47 |
<div align="center">
|
48 |
-
<h1
|
|
|
49 |
|
50 |
-
[![Github Badge](https://img.shields.io/github/stars/
|
51 |
</div>
|
52 |
''', unsafe_allow_html=True)
|
53 |
st.markdown('---')
|
|
|
39 |
|
40 |
def main():
|
41 |
st.set_page_config(layout="wide")
|
42 |
+
posts = ['posts/1_blog_in_spaces.md']
|
43 |
+
page_to_show = posts[0]
|
44 |
with st.sidebar:
|
45 |
|
46 |
st.markdown('''
|
47 |
<div align="center">
|
48 |
+
<h1>π€ Tips & Tricks</h1>
|
49 |
+
<p>Learn power user tips of things you can do at Hugging Face. Learn about latest features and more!</p>
|
50 |
|
51 |
+
[![Github Badge](https://img.shields.io/github/stars/osanseviero/hf-tips-and-tricks?style=social)](https://github.com/osanseviero/hf-tips-and-tricks)
|
52 |
</div>
|
53 |
''', unsafe_allow_html=True)
|
54 |
st.markdown('---')
|
images/huggingface_logo.png β assets/1_huggingface_logo.png
RENAMED
File without changes
|
assets/1_streamlit_space.png
ADDED
posts/1_blog_in_spaces.md
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: T&T1 - Create interactive blog posts with Streamlit and Spaces
|
3 |
+
description: Learn about how to host interactive blogs using Streamlit, GitHub and Spaces.
|
4 |
+
date: 2022-01-20
|
5 |
+
thumbnail: assets/1_huggingface_logo.png
|
6 |
+
---
|
7 |
+
|
8 |
+
# π€ Tips & Tricks Edition 1
|
9 |
+
# Create interactive blog posts with Streamlit and Spaces
|
10 |
+
|
11 |
+
Welcome to the first post of the π€ Tips and Tricks blog! In this blog, I'll be sharing features you might not know about to leverage the Hub platform and Open Source ecosystem at its full extent.
|
12 |
+
|
13 |
+
In today's post, you'll learn how this blog was actually done! This is actually very easy and the setup takes less than 10 minutes!
|
14 |
+
|
15 |
+
## Workflow
|
16 |
+
|
17 |
+
I'm a strong believer that there are different tools for different jobs. The tools we'll use today are:
|
18 |
+
|
19 |
+
* **Streamlit**: A very cool Open Source library that allows to build apps in Python in a very straightforward way.
|
20 |
+
* **GitHub**: The main platform in which we're going to be doing the coding.
|
21 |
+
* **Hugging Face Hub**: The platform in which the demo will be hosted using [Spaces](http://hf.co/spaces/launch), a platform through which you can freely share ML demos using Streamlit, Gradio or even static sites (HTML & JavaScript if you're into that stuff).
|
22 |
+
|
23 |
+
Note: this is not a fully-fledged blog platform. There won't be subscribe options, for example, but it's a cool proof of concept that can be interesting for certain interactive articles.
|
24 |
+
|
25 |
+
**Sure sure...but how does it work?**
|
26 |
+
|
27 |
+
So you will have a Streamlit-based application in which you'll have your articles. The code will be in GitHub, and through GitHub Action workflows, the blog will be automatically sync'ed to a Hugging Face Space.
|
28 |
+
|
29 |
+
**Sounds fun, let's do it!**
|
30 |
+
|
31 |
+
Cool! So Nate has built a [nice template](https://github.com/nateraw/host-a-blog-on-huggingface-spaces) we can already use out of the box. Isn't that cool? Let's begin by clicking that **Fork** button in GitHub. Nice, so you're getting ready. Let's quickly explore what we have here
|
32 |
+
|
33 |
+
- **.github/workflows/**: There is a GitHub Actions workflow that will automatically sync to the Hugging Face Hub each time you push into the repo.
|
34 |
+
- **images/**: Well...it contains images.
|
35 |
+
* **posts/**: You can write your articles here directly with Markdown!.
|
36 |
+
* **app.py**: This is the main application file that has the structure of the blog.
|
37 |
+
* **packages.txt** and **requirements.txt** allow you to specify any dependencies you'll want to have installed in the blog. If you want to show some cool visualization using library X, you can add X here!
|
38 |
+
|
39 |
+
**Can we get this started?**
|
40 |
+
|
41 |
+
Yes, let's do it. First, create a [new Space](https://huggingface.co/new-space) at Hugging Face. You will need to specify the Streamlit SDK. Since it's still being setup, you can make it private so others don't see it. The Space can have any name you want.
|
42 |
+
|
43 |
+
![Image of Spaces](assets/1_streamlit_space.png)
|
44 |
+
|
45 |
+
|
46 |
+
The second step is to create a [write token](https://huggingface.co/settings/token). This will allow GitHub to push whenever there are changes to the Space.
|
posts/check_this_out.md
DELETED
@@ -1,10 +0,0 @@
|
|
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
DELETED
@@ -1,10 +0,0 @@
|
|
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
CHANGED
@@ -1 +1,2 @@
|
|
1 |
streamlit
|
|
|
|
1 |
streamlit
|
2 |
+
pyyaml
|