Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,30 +5,38 @@ import sys
|
|
5 |
|
6 |
HTML_TEMPLATE = '''<!DOCTYPE html>
|
7 |
<html>
|
|
|
8 |
<head>
|
9 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</head>
|
|
|
11 |
<body>
|
12 |
<h1>Result:</h1>
|
13 |
{content}
|
14 |
</body>
|
|
|
15 |
</html>
|
16 |
'''
|
17 |
|
18 |
VIS_TEMPLATE = '''
|
19 |
<div id="container" class="mol-container"></div>
|
20 |
<script>
|
21 |
-
|
22 |
-
let
|
23 |
-
|
24 |
-
$
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
viewer.render();
|
31 |
-
})
|
32 |
</script>
|
33 |
'''
|
34 |
|
@@ -39,7 +47,7 @@ def generate(input_file):
|
|
39 |
except:
|
40 |
return HTML_TEMPLATE.format(content='Error: could not open the provided file')
|
41 |
|
42 |
-
content = VIS_TEMPLATE
|
43 |
return HTML_TEMPLATE.format(content=content)
|
44 |
|
45 |
|
|
|
5 |
|
6 |
HTML_TEMPLATE = '''<!DOCTYPE html>
|
7 |
<html>
|
8 |
+
|
9 |
<head>
|
10 |
+
<style>
|
11 |
+
.mol-container {
|
12 |
+
width: 60%;
|
13 |
+
height: 400px;
|
14 |
+
position: relative;
|
15 |
+
}
|
16 |
+
</style>
|
17 |
+
<script src="http://3Dmol.csb.pitt.edu/build/3Dmol-min.js""></script>
|
18 |
</head>
|
19 |
+
|
20 |
<body>
|
21 |
<h1>Result:</h1>
|
22 |
{content}
|
23 |
</body>
|
24 |
+
|
25 |
</html>
|
26 |
'''
|
27 |
|
28 |
VIS_TEMPLATE = '''
|
29 |
<div id="container" class="mol-container"></div>
|
30 |
<script>
|
31 |
+
$(function() {
|
32 |
+
let element = $('#container');
|
33 |
+
let config = { backgroundColor: 'orange' };
|
34 |
+
let viewer = $3Dmol.createViewer( element, config );
|
35 |
+
viewer.addSphere({ center: {x:0, y:0, z:0}, radius: 10.0, color: 'green' });
|
36 |
+
viewer.zoomTo();
|
37 |
+
viewer.render();
|
38 |
+
viewer.zoom(0.8, 2000);
|
39 |
+
});
|
|
|
|
|
40 |
</script>
|
41 |
'''
|
42 |
|
|
|
47 |
except:
|
48 |
return HTML_TEMPLATE.format(content='Error: could not open the provided file')
|
49 |
|
50 |
+
content = VIS_TEMPLATE
|
51 |
return HTML_TEMPLATE.format(content=content)
|
52 |
|
53 |
|