Python CGI: Difference between revisions
→Troubleshooting
No edit summary |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 122:
http://10.140.196.7/cgi-bin/index.py
= Javascripts =
<syntaxhighlight lang="Python">
#!/usr/bin/python3
import json
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
path = form.getvalue('path')
#Avi Config Loader
f = open("avi_config",'r')
config = json.load(f)
f.close
print("Content-Type: text/html;charset=utf-8\r\n\r\n")
print ("""
<!DOCTYPE html>
<html lang="en">
<title>Tech Support Analyzer Tool</title>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
html,body,h1,h2,h3,h4,h5,h6 {font-family: "Roboto", sans-serif;}
.w3-sidebar {
z-index: 3;
width: 250px;
top: 43px;
bottom: 0;
height: inherit;
}
</style>
<script src="/json-browse/jquery-3.4.1.slim.js"></script>
<script src="/json-browse/jquery.json-browse.js"></script>
<link href="/json-browse/jquery.json-browse.css"rel="stylesheet">
<script type="text/javascript">
window.onload=function(){
$('#json-renderer').jsonBrowse("""+str(convert(config["Tenant"]))+""",{
collapsed: true
});
}
</script>
</head>
<body>
""")
print('<pre id="json-renderer" class="json-body"></pre>')
print ("""
<!-- END MAIN -->
</body>
</html>
""")
</syntaxhighlight>
== Troubleshooting ==
* If the Javascript is not loading & you are getting HTTP Error code 500 in the browser, Need to move the JS files output of the CGI-BIN directory.
* Every time you trying to access any file within cgi-bin path it is expecting that content will be generated by executing that file.
https://serverfault.com/questions/672189/how-do-i-prevent-apache2-from-trying-to-execute-a-file-as-a-script
<br />
|