Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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