-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
42 lines (36 loc) · 1.3 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import urllib
import streamlit as st
import pendulum as pdlm
from io import StringIO
from contextlib import contextmanager, redirect_stdout
import jingjue
@contextmanager
def st_capture(output_func):
with StringIO() as stdout, redirect_stdout(stdout):
old_write = stdout.write
def new_write(string):
ret = old_write(string)
output_func(stdout.getvalue())
return ret
stdout.write = new_write
yield
def get_file_content_as_string(path):
url = 'https://raw.githubusercontent.com/kentang2017/kinqimen/master/' + path
response = urllib.request.urlopen(url)
return response.read().decode("utf-8")
def get_file_content_as_string1(path):
url = 'https://raw.githubusercontent.com/kentang2017/kinliuren/master/' + path
response = urllib.request.urlopen(url)
return response.read().decode("utf-8")
st.set_page_config(layout="wide",page_title="堅荊訣占")
pan,links = st.tabs([' 排盤 ', ' 連結 ' ])
with links:
st.header('連結')
st.markdown(get_file_content_as_string1("update.md"), unsafe_allow_html=True)
with pan:
st.header('排盤')
output = st.empty()
with st_capture(output.code):
print("干卦︰"+jingjue.qigua()[0])
print("")
print("卦義︰"+jingjue.qigua()[1])