Created
May 2, 2020 07:52
-
-
Save wfng92/964a8f4fad7395bb93a32c66612e9183 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import api_data | |
import random | |
server_port = 5000 | |
app = Flask(__name__) | |
@app.route('/joke-api') | |
def joke(): | |
language = request.args.get('language', 'en') | |
if(language not in api_data.joke_dict): | |
language = 'en' | |
return random.choice(api_data.joke_dict[language]) | |
if __name__ == "__main__": | |
app.run('0.0.0.0',port=server_port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment