Giter Site home page Giter Site logo

noops-challenge / fizzbot Goto Github PK

View Code? Open in Web Editor NEW
45.0 7.0 123.0 12 KB

Fizzbot has questions for you... so many questions. A FizzBuzz API for you to play with.

Home Page: https://noopschallenge.com/challenges/fizzbot

Ruby 29.75% Python 70.25%
fizzbuzz

fizzbot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fizzbot's Issues

fizz3.py errors on run

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.

Favorite Programming Language incorrect answer

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?

500 Internal server error when posting answer

$ 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"
}

No access through browser request

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: *

chromenetwork

chromelog

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.