Requests:
this.$axios.put('http://192.168.0.103:3389', {teste: 'teste'}).then(function (res) {
console.log('RESULTADO:', res.data)
self.users = res.data
})
this.$http.delete('http://192.168.0.103:3389').then(function (res) {
console.log('RESULTADO:', res.body)
self.users = res.body
})
server.py
from http.server import *
import json
class Server():
def __init__(self):
pass
class Server(BaseHTTPRequestHandler):
SERVER = Server()
def do_OPTIONS(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Expose-Headers", "Access-Control-Allow-Origin")
self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Request-Method", "*")
self.end_headers()
self.wfile.write(json.dumps({'OPTIONS': 'teste'}).encode('utf-8'))
def do_POST(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Expose-Headers", "Access-Control-Allow-Origin")
self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Request-Method", "*")
self.end_headers()
self.wfile.write(json.dumps({'POST': 'teste'}).encode('utf-8'))
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Expose-Headers", "Access-Control-Allow-Origin")
self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Request-Method", "*")
self.end_headers()
self.wfile.write(json.dumps({'GET': 'teste'}).encode('utf-8'))
def do_PUT(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Expose-Headers", "Access-Control-Allow-Origin")
self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Request-Method", "*")
self.end_headers()
self.wfile.write(json.dumps({'PUT': 'teste'}).encode('utf-8'))
def do_DELETE(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Expose-Headers", "Access-Control-Allow-Origin")
self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Request-Method", "*")
self.end_headers()
self.wfile.write(json.dumps({'DELETE': 'teste'}).encode('utf-8'))
httpd = HTTPServer(192;168;0;103, 3389), Server)
print('Open in', httpd.server_address)
httpd.serve_forever()