1# Note: The last time I tested something was missing so I couldn't work
2import pathlib
3import transpyle
4
5path = pathlib.Path('my_script.py')
6code_reader = transpyle.CodeReader()
7code = code_reader.read_file(path)
8
9from_language = transpyle.Language.find('Python 3.6')
10to_language = transpyle.Language.find('Fortran 95')
11translator = transpyle.AutoTranslator(from_language, to_language)
12fortran_code = translator.translate(code, path)
13print(fortran_code)
14
1#import socket module
2from socket import *
3serverSocket = socket(AF_INET, SOCK_STREAM)
4#Prepare a sever socket
5TCP_PORT = 8000
6BUFFER_SIZE = 1024
7
8serverSocket.bind(('', TCP_PORT))
9serverSocket.listen(1)
10
11while True:
12 #Establish the connection
13 print 'Ready to serve...'
14 connectionSocket, addr = serverSocket.accept()
15
16 print 'Connection address:', addr
17
18 try:
19 message = connectionSocket.recv(BUFFER_SIZE)
20 filename = message.split()[1]
21 f = open(filename[1:])
22 outputdata = f.read()
23
24 #Send one HTTP header line into socket
25 connectionSocket.send('HTTP/1.0 200 OK\r\n')
26
27 #Send the content of the requested file to the client
28
29 for i in range(0, len(outputdata)):
30 connectionSocket.send(outputdata[i])
31
32 connectionSocket.close()
33
34 except IOError:
35 #Send response message for file not found
36 fail = '''<html> <head> <title> 404 </title> </head> <body><h1>404 Bruh</h1> <h3> hushies! </h3> </body></html>'''
37
38 connectionSocket.send('HTTP/1.0 200 OK\r\n'%len(fail))
39
40 for q in fail:
41 connectionSocket.send(q)
42
43 #Close client socket
44
45 serverSocket.close(