Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,57 +3,47 @@ import os
|
|
| 3 |
import sys
|
| 4 |
|
| 5 |
|
| 6 |
-
HTML_TEMPLATE = '''
|
|
|
|
| 7 |
<html>
|
| 8 |
-
|
| 9 |
-
<
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
<
|
| 23 |
-
<
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</html>
|
| 28 |
'''
|
| 29 |
|
| 30 |
-
VIS_TEMPLATE = '''
|
| 31 |
-
<div id="container" class="mol-container"></div>
|
| 32 |
-
<script>
|
| 33 |
-
$(function() {
|
| 34 |
-
let element = $('#container');
|
| 35 |
-
let config = { backgroundColor: 'orange' };
|
| 36 |
-
let viewer = $3Dmol.createViewer( element, config );
|
| 37 |
-
viewer.addSphere({ center: {x:0, y:0, z:0}, radius: 10.0, color: 'green' });
|
| 38 |
-
viewer.zoomTo();
|
| 39 |
-
viewer.render();
|
| 40 |
-
viewer.zoom(0.8, 2000);
|
| 41 |
-
});
|
| 42 |
-
</script>
|
| 43 |
-
'''
|
| 44 |
-
|
| 45 |
-
PARAMS = '''<iframe style="width: 100%; height: 700px" name="result" allow="midi; geolocation; microphone; camera; display-capture; encrypted-media;" sandbox="allow-modals allow-forms allow-scripts allow-same-origin allow-popups allow-top-navigation-by-user-activation allow-downloads" allowfullscreen="" allowpaymentrequest="" frameborder="0" srcdoc='{html}'></iframe>'''
|
| 46 |
-
|
| 47 |
-
|
| 48 |
def generate(input_file):
|
| 49 |
try:
|
| 50 |
path = input_file.name
|
| 51 |
except:
|
| 52 |
-
return
|
| 53 |
|
| 54 |
-
|
| 55 |
-
html = HTML_TEMPLATE.format(content=content)
|
| 56 |
-
return PARAMS.format(html=html)
|
| 57 |
|
| 58 |
|
| 59 |
demo = gr.Blocks()
|
|
|
|
| 3 |
import sys
|
| 4 |
|
| 5 |
|
| 6 |
+
HTML_TEMPLATE = '''
|
| 7 |
+
<!DOCTYPE html>
|
| 8 |
<html>
|
| 9 |
+
<head>
|
| 10 |
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
| 11 |
+
<style>
|
| 12 |
+
.mol-container {
|
| 13 |
+
width: 600px;
|
| 14 |
+
height: 600px;
|
| 15 |
+
position: relative;
|
| 16 |
+
mx-auto:0
|
| 17 |
+
}
|
| 18 |
+
</style>
|
| 19 |
+
<script src="http://3Dmol.csb.pitt.edu/build/3Dmol-min.js""></script>
|
| 20 |
+
</head>
|
| 21 |
+
|
| 22 |
+
<body>
|
| 23 |
+
<h1>Result:</h1>
|
| 24 |
+
<div id="container" class="mol-container"></div>
|
| 25 |
+
<script>
|
| 26 |
+
$(function() {
|
| 27 |
+
let element = $('#container');
|
| 28 |
+
let config = { backgroundColor: 'orange' };
|
| 29 |
+
let viewer = $3Dmol.createViewer( element, config );
|
| 30 |
+
viewer.addSphere({ center: {x:0, y:0, z:0}, radius: 10.0, color: 'green' });
|
| 31 |
+
viewer.zoomTo();
|
| 32 |
+
viewer.render();
|
| 33 |
+
viewer.zoom(0.8, 2000);
|
| 34 |
+
});
|
| 35 |
+
</script>
|
| 36 |
+
</body>
|
| 37 |
</html>
|
| 38 |
'''
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def generate(input_file):
|
| 41 |
try:
|
| 42 |
path = input_file.name
|
| 43 |
except:
|
| 44 |
+
return 'Error: could not open the provided file'
|
| 45 |
|
| 46 |
+
return HTML_TEMPLATE
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
demo = gr.Blocks()
|