Ahmadt commited on
Commit
132b865
·
1 Parent(s): 1388359

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +192 -18
index.html CHANGED
@@ -1,19 +1,193 @@
1
- <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
  <html>
3
+ <head>
4
+ <title id="header-title"></title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
7
+ <link rel="icon" type="image/png" href="./favicon.png" />
8
+ <link
9
+ rel="stylesheet"
10
+ href="https://pyscript.net/latest/pyscript.css"
11
+ />
12
+ <script defer src="https://pyscript.net/latest/pyscript.js"></script>
13
+
14
+ <link rel="stylesheet" href="./assets/css/examples.css" />
15
+ </head>
16
+
17
+ <body>
18
+ <nav class="navbar" style="background-color: #000000">
19
+ <div class="app-header">
20
+ <a href="/">
21
+ <img src="./logo.png" class="logo" />
22
+ </a>
23
+ <a
24
+ class="title"
25
+ id="page-title"
26
+ href=""
27
+ style="color: #f0ab3c"
28
+ ></a>
29
+ </div>
30
+ </nav>
31
+
32
+ <br />
33
+ <div id="page-message"></div>
34
+
35
+ <div id="pandas-source">
36
+ <h3>Data Source</h3>
37
+ <input type="text" id="txt-url" class="py-input" size="70" />
38
+ <button
39
+ type="submit"
40
+ id="btn-load"
41
+ class="py-button"
42
+ py-click="loadFromURL()"
43
+ >
44
+ Load CSV
45
+ </button>
46
+ </div>
47
+
48
+ <div id="pandas-repl" hidden>
49
+ <h3>Python REPL</h3>
50
+ <py-repl id="pandas-repl-inner" output="pandas-output-inner">
51
+ # Hit SHIFT + ENTER to execute example code # Get all closed
52
+ airports in Great Britain df2 = df.query("type == 'closed' &
53
+ iso_country == 'GB'") df2
54
+ </py-repl>
55
+ </div>
56
+
57
+ <div id="pandas-output" hidden>
58
+ <h3>Output</h3>
59
+ <div id="pandas-output-inner"></div>
60
+ </div>
61
+
62
+ <div id="pandas-dev-console" hidden>
63
+ <h3>Dev Console</h3>
64
+ <py-terminal auto></py-terminal>
65
+ </div>
66
+
67
+ <py-tutor>
68
+ <py-config>
69
+ plugins = [
70
+ "https://pyscript.net/latest/plugins/python/py_tutor.py"
71
+ ]
72
+ packages = ["pandas", "pyactr"]
73
+ </py-config>
74
+
75
+ <section class="pyscript">
76
+ <py-script>
77
+ await micropip.install("setuptools")
78
+ import pyactr as actr
79
+ actr.chunktype("word", "form, meaning, category, number, synfunction")
80
+ actr.chunktype("goal_lexeme", "task, category, number")
81
+
82
+ carLexeme = actr.chunkstring(string="""
83
+ isa word
84
+ form car
85
+ meaning '[[car]]'
86
+ category noun
87
+ number sg
88
+ synfunction subject
89
+ """)
90
+
91
+ agreement = actr.ACTRModel()
92
+ dm = agreement.decmem
93
+ dm.add(carLexeme)
94
+ agreement.productionstring(name="retrieve", string="""
95
+ =g>
96
+ isa goal_lexeme
97
+ category verb
98
+ task agree
99
+ ?retrieval>
100
+ buffer empty
101
+ ==>
102
+ =g>
103
+ isa goal_lexeme
104
+ task trigger_agreement
105
+ category verb
106
+ +retrieval>
107
+ isa word
108
+ category noun
109
+ synfunction subject
110
+ """)
111
+
112
+ agreement.productionstring(name="agree", string="""
113
+ =g>
114
+ isa goal_lexeme
115
+ task trigger_agreement
116
+ category verb
117
+ =retrieval>
118
+ isa word
119
+ category noun
120
+ synfunction subject
121
+ number =x
122
+ ==>
123
+ =g>
124
+ isa goal_lexeme
125
+ category verb
126
+ number =x
127
+ task done
128
+ """)
129
+
130
+ agreement.productionstring(name="done", string="""
131
+ =g>
132
+ isa goal_lexeme
133
+ task done
134
+ ==>
135
+ ~g>
136
+ """)
137
+ import pandas as pd
138
+ from pyodide.http import open_url
139
+ import sys
140
+
141
+ title = "Pandas (and basic DOM manipulation)"
142
+ page_message = "This example loads a remote CSV file into a Pandas dataframe, displays it and lets you manipulate it through a Python REPL"
143
+
144
+ url = "https://raw.githubusercontent.com/datasets/airport-codes/master/data/airport-codes.csv"
145
+
146
+ Element("header-title").element.innerText = title
147
+ Element("page-title").element.innerText = title
148
+ Element("page-message").element.innerText = page_message
149
+
150
+ Element("txt-url").element.value = url
151
+
152
+ # Depending on the type of DOM element, there are several alternative methods to write to it
153
+ # Element("id-of-dom-element").write("example")
154
+ # Element("id-of-dom-element").innerText = "example"
155
+ # Element("id-of-dom-element").value = "example"
156
+ # Element("id-of-dom-element").element.innerText = "example"
157
+ # Element("id-of-dom-element").element.value = "example"
158
+ # js.document.getElementById("id-of-dom-element").innerText = "example"
159
+ # js.document.getElementById("id-of-dom-element").value = "example"
160
+
161
+ df = pd.DataFrame()
162
+
163
+
164
+ def loadFromURL(*args, **kws):
165
+ global df
166
+
167
+ # clear dataframe & output
168
+ df = pd.DataFrame()
169
+ Element("pandas-output-inner").element.innerHTML = ""
170
+
171
+ url = Element("txt-url").element.value
172
+ log ("Trying to fetch CSV from " + url)
173
+
174
+ df = pd.read_csv(open_url(url))
175
+
176
+ Element("pandas-repl").element.style.display = "block"
177
+ Element("pandas-output").element.style.display = "block"
178
+ Element("pandas-dev-console").element.style.display = "block"
179
+
180
+ display (df, target="pandas-output-inner", append="False")
181
+
182
+ def log(message):
183
+ # log to pyscript dev console
184
+ print ("0123", message)
185
+ message1="aso"
186
+
187
+ # log to JS console
188
+ js.console.log (message)
189
+ </py-script>
190
+ </section>
191
+ </py-tutor>
192
+ </body>
193
+ </html>