I want to make a server that returns text and image at the same time, only using python socket and not using...
up vote
1
down vote
favorite
Problem is that I cannot get my image files
- Should I encode image files to binaryarras?
How can I put use utf-8 and base64 at the same time to make image and text show up at the same time...
##
import socket
import base64
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('127.0.0.1', 8080))
server_socket.listen(1)
print('listening')
while True:
connect_socket, addr = server_socket.accept()
data = connect_socket.recv(99999)
print('data received : ',data.decode())
connect_socket.sendall("""HTTP/1.1 200 OK
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="Content-Type" content="image/jpeg;charset=UTF-8" />
<title>Happy pig</title>
</head>
<body>
<font color=#55C0F1 size=10>
<h1>
"Hi"
<img src="pig.jpg" width= "137" height="150">
</h1>
</font>
</form>
</body>
</html>""".encode('utf-8'))
connect_socket.close()
##
html serversocket python-sockets
add a comment |
up vote
1
down vote
favorite
Problem is that I cannot get my image files
- Should I encode image files to binaryarras?
How can I put use utf-8 and base64 at the same time to make image and text show up at the same time...
##
import socket
import base64
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('127.0.0.1', 8080))
server_socket.listen(1)
print('listening')
while True:
connect_socket, addr = server_socket.accept()
data = connect_socket.recv(99999)
print('data received : ',data.decode())
connect_socket.sendall("""HTTP/1.1 200 OK
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="Content-Type" content="image/jpeg;charset=UTF-8" />
<title>Happy pig</title>
</head>
<body>
<font color=#55C0F1 size=10>
<h1>
"Hi"
<img src="pig.jpg" width= "137" height="150">
</h1>
</font>
</form>
</body>
</html>""".encode('utf-8'))
connect_socket.close()
##
html serversocket python-sockets
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Problem is that I cannot get my image files
- Should I encode image files to binaryarras?
How can I put use utf-8 and base64 at the same time to make image and text show up at the same time...
##
import socket
import base64
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('127.0.0.1', 8080))
server_socket.listen(1)
print('listening')
while True:
connect_socket, addr = server_socket.accept()
data = connect_socket.recv(99999)
print('data received : ',data.decode())
connect_socket.sendall("""HTTP/1.1 200 OK
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="Content-Type" content="image/jpeg;charset=UTF-8" />
<title>Happy pig</title>
</head>
<body>
<font color=#55C0F1 size=10>
<h1>
"Hi"
<img src="pig.jpg" width= "137" height="150">
</h1>
</font>
</form>
</body>
</html>""".encode('utf-8'))
connect_socket.close()
##
html serversocket python-sockets
Problem is that I cannot get my image files
- Should I encode image files to binaryarras?
How can I put use utf-8 and base64 at the same time to make image and text show up at the same time...
##
import socket
import base64
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('127.0.0.1', 8080))
server_socket.listen(1)
print('listening')
while True:
connect_socket, addr = server_socket.accept()
data = connect_socket.recv(99999)
print('data received : ',data.decode())
connect_socket.sendall("""HTTP/1.1 200 OK
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="Content-Type" content="image/jpeg;charset=UTF-8" />
<title>Happy pig</title>
</head>
<body>
<font color=#55C0F1 size=10>
<h1>
"Hi"
<img src="pig.jpg" width= "137" height="150">
</h1>
</font>
</form>
</body>
</html>""".encode('utf-8'))
connect_socket.close()
##
html serversocket python-sockets
html serversocket python-sockets
edited Nov 10 at 11:31
eibersji
441420
441420
asked Nov 10 at 10:39
Seyoung Kim
61
61
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45
add a comment |
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238109%2fi-want-to-make-a-server-that-returns-text-and-image-at-the-same-time-only-using%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It seems multipart responses are not possible
– digitalarbeiter
Nov 11 at 8:45