leahcimto / randomjokeapi Goto Github PK
View Code? Open in Web Editor NEWSimple API that gives random jokes
Home Page: https://randomjokeapi.leahcimto.repl.co/
License: MIT License
Simple API that gives random jokes
Home Page: https://randomjokeapi.leahcimto.repl.co/
License: MIT License
Line 15 in 67f681d
return { "joke": random.choice(jokes) }
There is no competition here.
random.choice(jokes)
> jokes[random.randrange(0, len(jokes))]
Currently, you're using a JSON file to store the API, but I think that you should use TXT instead.
It's really easy to switch even, just use
jokes = file.read().split("\n")
in main.py
on line 8(also, make sure line 7 uses jokes.txt
instead of jokes.json
).
Here are some reasons for switching over:
I've also already made it into a txt
doc:
What's the best thing about Switzerland? I don't know, but the flag is a big plus.
Someone tells his doctor, "Doc, help me. I'm addicted to Twitter!" The doctor replies, "Sorry, I don't follow you…"
What did the 0 say to the 8? Nice belt!
I used to think the brain was the most important organ. Then I thought, look what's telling me that.
Do you want to hear a construction joke? Sorry, I'm still working on it.
What gets wetter the more it dries? A towel.
How does NASA organize a party? They planet.
Why does Humpty Dumpty love autumn? Because Humpty Dumpty had a great fall.
Why was the math book sad? Because it had so many problems.
If you see a robbery at an Apple Store does that make you… an iWitness?!
Why did Karen press CTRL + Alt + Delete? She wanted the Task Manager.
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.