What I've done: I've created a small HTTP server python, using no modules but socket. It manages to start, load HTML and then send it out,
so you can see the HTML file in your browser.
What I'm using: I'm using Python 3.5.1, I'm also using Socket.
The problem: Images do not show on the web browser.
Here is the code I have put together:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = ''
PORT = 8888
asked_url = []
s.bind((HOST, PORT))
s.listen(1)
while True:
conn, addr = s.accept()
request = conn.recv(1024)
html_file = open("page.html", 'rb')
try:
http_response = html_file.read()
conn.sendall(http_response)
conn.sendall(b'<p><small>PyWeb</small></p>')
except:
print("Couldn't send any data! Passing...")
pass
conn.close()
Here is also the HTML code for the page, However it doesn't seem to be the problem:
<script src="https://mcapi.us/scripts/minecraft.js"></script>
<div class="server-status">
My awesome server is currently <span class="server-online"></span>!
</div>
<script>
MinecraftAPI.getServerStatus('SERVER HERE', {
port: 25565 // optional, only if you need a custom port
}, function (err, status) {
if (err) {
return document.querySelector('.server-status').innerHTML = 'Error loading status';
}
// you can change these to your own message!
document.querySelector('.server-online').innerHTML = status.online ? 'up' : 'down';
});
</script>
<img src="test.png" alt="Test Image" style="width:304px;height:228px;">
What the HTML code does: Shows text and an image.
If you need more detail just ask.