Created
June 13, 2018 19:10
-
-
Save carzacc/b35f0a0bb600b16d8662366e55c8b2dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
app = Flask(__name__) | |
# The Fibonacci function | |
def fibo(n: int): | |
""" | |
Calculating the fibonacci numbers | |
""" | |
if n < 1: | |
return 0 | |
elif n == 1: | |
return 1 | |
else: | |
return fibo(n-1)+fibo(n-2) | |
# The actual route | |
@app.route("/") | |
def send_fibo(): | |
""" | |
Sending the fibonacci number to the user, telling him if | |
he uses improper input | |
""" | |
try: | |
return str(fibo(int(request.args['n']))) | |
except ValueError: | |
return "Please use a number as the 'n' argument" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment