noops-challenge / fizzbot Goto Github PK
View Code? Open in Web Editor NEWFizzbot has questions for you... so many questions. A FizzBuzz API for you to play with.
Home Page: https://noopschallenge.com/challenges/fizzbot
Fizzbot has questions for you... so many questions. A FizzBuzz API for you to play with.
Home Page: https://noopschallenge.com/challenges/fizzbot
The noops API is blocking POST requests made from javascript through the browser. POST request seem to be allowed but the mandatory pre-flight OPTIONS request is not allowed by the server. The following headers are returned by the API:
access-control-allow-methods: GET,HEAD,PUT,PATCH,POST,DELETE
access-control-allow-origin: *
I am making the request as follows:
axios.post(url, options, {
headers: {
'Content-type': 'application/application/json',
},
}).then(response => {
console.log(response)
})
Is there any way to include OPTIONS requests in the allowed methods?
The following request gives me an error:
curl -X POST -d {"answer":"python"} https://api.noopschallenge.com/fizzbot/questions/1
{"message":"Please provide an answer that is a string.","result":"incorrect"}
But I have followed the example response:
"exampleResponse":{"answer":"COBOL"}
What am I missing here?
$ http -v POST https://api.noopschallenge.com/fizzbot/questions/MAGNBflYDdufbSDrUX_sTvZ8MwgPXZ-kQU__q4pP8H4 answer:='[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"FizzBuzz"]'
POST /fizzbot/questions/MAGNBflYDdufbSDrUX_sTvZ8MwgPXZ-kQU__q4pP8H4 HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 99
Content-Type: application/json
Host: api.noopschallenge.com
User-Agent: HTTPie/1.0.2
{
"answer": [
1,
2,
"Fizz",
4,
"Buzz",
"Fizz",
7,
8,
"Fizz",
"Buzz",
11,
"Fizz",
13,
14,
"FizzBuzz"
]
}
HTTP/1.1 500 Internal Server Error
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 45
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Jun 2019 21:06:30 GMT
ETag: W/"2d-rNKQTDvGLnuBDl7snD1HaRm3E1Q"
Vary: Accept-Encoding
X-Powered-By: Express
cache-control: private, max-age:0
{
"message": "actual.charAt is not a function"
}
Output on running the program:
----------------------------------------------------------------------
*** GET /fizzbot
Traceback (most recent call last):
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 956, in send
self.connect()
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 928, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 727, in create_connection
raise err
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\aadibajpai\Desktop\fizz.py", line 76, in <module>
if __name__ == '__main__': main()
File "C:\Users\aadibajpai\Desktop\fizz.py", line 74, in main
question_url = do_question(domain, question_url)
File "C:\Users\aadibajpai\Desktop\fizz.py", line 60, in do_question
request = urllib.request.urlopen( ('%s%s' % (domain, question_url)) )
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1345, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
Not sure how to fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.