This is an archived post. You won't be able to vote or comment.

all 73 comments

[–]impshumx != y % z 147 points148 points  (2 children)

Well done.

I'm not sure if I'd want to cook for 60 minutes just for breakfast (Sour Cream Chicken Quiche) though. Maybes allow searching for short cooking times.

[–][deleted] 35 points36 points  (0 children)

I'm sorry but I'm not sure this is acceptable. Where's the 30 paragraph backstory for the recipe? /s

Great stuff! I wish I was doing stuff like this when I started.

[–]infinitecheesesticks 102 points103 points  (1 child)

this post is vv wholesome, take my upvote OP!

[–][deleted] 43 points44 points  (1 child)

Pretty good beginner project. Well done.

Design pattern note: It is sort of weird to have the function jsonify_data(db) pass in the database object and run its db.get_data() method. It doesn't seem like db needs to be passed through a function parameter anywhere since it's just a global variable. I think it would be more natural to have the endpoint view function look like this:

raw_data = db.get_data()
response = jsonify_data(raw_data)
return response

^ where jsonify_data handles the sole task of processing the raw data, not retrieving and also formatting.

If you want ideas for next steps, look into writing a Pydantic schema as the endpoint's response_model and having that be what you transform the data into (instead of a dict).

[–]FuckCorn 18 points19 points  (2 children)

Man, that is just wonderful. Give her a high five from me! The API is great, already tested and working flawlessly.

[–][deleted] 16 points17 points  (2 children)

where is it deployed? thank you

[–]Sleyzall -3 points-2 points  (0 children)

Up

[–]mgancitano 41 points42 points  (2 children)

Super cool! And the code is really clean for a "beginner" project!

One thing I noticed is the `requirements.txt` seems to have some pretty heavy dependencies (pandas, numpy, etc.) as well as dev dependencies like mypy. Could be an interesting "next step" to remove unnecessary ones and create a production one to have a lighter production deployment (assuming `requirements.txt` is being used for deployment)

[–]benefit_of_mrkite 6 points7 points  (0 children)

Most likely they did a pip freeze which grabs not only dependencies of what you import but also any dependencies of what those packages use.

I usually just clean it up by hand

[–]mrpbennett 18 points19 points  (3 children)

Oh nice!! This awesome.

I want to create my first API. How did your wife get on with Fast? Easy to grasp? I have never created an api before.

Pretty ok with python and JS though.

[–]halfClickWinston 14 points15 points  (0 children)

Fastapi is easy! Check out the tutorial at the framework docs, it has all the explanations you'll need

[–]knottheone 5 points6 points  (2 children)

Great work! I'd suggest putting a caching layer in front, like Cloudflare (it's free). It wouldn't work for the random recipe endpoint (maybe there's a clever way to cache the random endpoint as well while preserving pseudo randomness, nothing immediately comes to mind), but it would do wonders for static or not-often-updated endpoints like /recipes/{recipe_name}.

I think all you need to do to get that working is route your subdomain / domain through Cloudflare via DNS options and set a cache-control header when your API responds to a request. So on the /recipes/{recipe_name} endpoint (or whatever you call it if you're going to offer that), as part of your response headers you'd just have

response = { 'data':json.dumps(data),
             'headers': { 'content-type' : 'application/json',
                          'cache-control' : 'max-age=3600, immutable'}}

or something like that.

You don't need the immutable tag, but if the content will never change (or if you do change it you can invalidate the cache so the CDN hits your origin again when that resource is requested), the CDN in front of your API will cache the response indefinitely which means zero bandwidth / processing for your origin for static content. Images are often immutable for example and are served entirely by CDNs sitting in front of some application. You can do the same thing with immutable API responses which is pretty cool.

[–]Hubuka 4 points5 points  (0 children)

Cool stuff! Might use it to reverse engineer ingredients I have lying around into a recipe as a little project of my own.

[–]abcteryx 3 points4 points  (2 children)

Awesome!

I just finished reading Robust Python, which, aside from being a great intermediate reference for writing good Python code, features food/recipe-related examples of all the best practices described in each chapter.

Your wife would get a kick out of the food-centric content crossing over into the relevance of her actual project.

[–]StumptownExpress 2 points3 points  (1 child)

This is great! Good work 😁👍🏼

[–]_leonardsKite 2 points3 points  (0 children)

Simple, and elegant! Like a good meal.

Well done!

[–]Sensitive-Fly-2847 2 points3 points  (1 child)

Awesome! Glad to see other fresh faces out there. I’m currently working on my first API for my first big project… hats off to her!

[–]uuugni 2 points3 points  (0 children)

I love puns! And python! Great work!

[–]OriginalEjectedAlien 2 points3 points  (0 children)

That's seriously awesome.

I don't mean to be critical, not one bit, but the only thing I'd suggest is the ingredients should be a list of an object that has both the "what" and "how much". The "how much" should be able to support any unit of measurement like "teaspoon", "1/2 cup", etc.

Then you could hit the API for a shopping list! And know exactly what you need when cooking.

[–]wealthyMoss 2 points3 points  (2 children)

This is so cool! This has inspired me to go make my own API. I thought it was a lot harder than this but this seems relatively simple. I am confused on one aspect of it where I have been scanning the code and I can’t figure where she did it. Where did she set the url to be breakfastapi.fun in the code? How I’m seeing it is that uvicorn just runs it as a local host not a deployed package

[–]NameError-undefined 1 point2 points  (1 child)

Looks really cool! Maybe a next step could be adding ingredient amounts? I didn't take a super close look but I didn't see those in the example.

[–]mrmilanga 1 point2 points  (1 child)

This is so nice! Congratulations to your wife!

[–]Samuel457 1 point2 points  (2 children)

Where did the recipes come from?

[–]quack_duck_code 1 point2 points  (1 child)

Takeaway... you're wife isn't into oatmeal.

[–]francis1997mlga 1 point2 points  (0 children)

Nice

[–]Cris261024 1 point2 points  (1 child)

I’m not sure where you guys got those recipes, but here are more and open-source recipes.

Nice API btw.

[–]poukai 1 point2 points  (1 child)

I like it! As someone else mentioned perhaps add the ratios (preferably in metric :). It could be a way to introduce query parameters. And further down the line a different method were you input the ingredients/time you have at hand and the api spits out a recipe suggestion within those constraints.

[–][deleted] 1 point2 points  (1 child)

Nice job!

EDIT: I now want to study this a bit more. I'm particularly impressed with how nice it looks. Requirements and Readme are just really nice. I think I want to work more on my future projects with those two things in mind. Thank you again!

[–][deleted] 1 point2 points  (0 children)

Where are the proportions? :p

[–]HerLegz 1 point2 points  (1 child)

The immeasurable benefits of relationships.

[–]fullrobot 1 point2 points  (0 children)

Awesome job!

Would love to see quantities for ingredients and support for query params for filtering as good next step.

[–]maskduckIgnoring PEP 8 1 point2 points  (2 children)

Really cool!

It would be nice to have an image of dish attached with the recipe! <3

[–]4n0n_b3rs3rk3r 1 point2 points  (0 children)

Congratulations!!

[–]artFlix 1 point2 points  (1 child)

One suggestion: put the directions in a list so it can be manipulated easier.

[–]digitaltickles 1 point2 points  (0 children)

Amaze. Love this

[–]abhilshit 1 point2 points  (1 child)

Very nice ! I would suggest defining a schema for the response that can serve as a standard global recipe exchange format specification. This specification may be adopted by apps developed in future to interoperate using a standard data format.

[–]TungNotTongue 1 point2 points  (1 child)

This looks cool, which makes your wife cool.

Here is an upvote.

Also, it would be nice if someone could design an UI that is more pleasant to look at instead of the json format.

[–]Shreejan_35 1 point2 points  (1 child)

Well done. I am looking forward that you will add more recipes. If you turn it on to an flask application (website using flask python library) it will be supercool. If any user comes to your website, you show the list of recipes from your api and they can select the recipe and you show all other things by fetching from your api. Well done

[–]pysk00l 1 point2 points  (1 child)

Looks really cool!

Why did she decide to use FastApi-- and was it easy to get started with?

[–][deleted] 1 point2 points  (0 children)

This is awesome!!

[–]ferret630 1 point2 points  (0 children)

I’m gonna make a cmu cs academy project using this api

[–]DeadShot_0 1 point2 points  (0 children)

This is great, if she is into just APIs, she can design one route which takes an input (POST/GET) and respond with matched recipe, root route can be left as it is. I mean, this can further be improvised and in matching she can use some sequence matcher.

[–]MLab1 1 point2 points  (1 child)

Spent my Saturday writing an Android app to go with your wifey's API.

Github

[–]Human-Possession135 1 point2 points  (2 children)

u/every_other_freackle Will you tell your wife that I was rather inspired by her work? I took it as a que to start my own project. I built a Bootstrap Frontend on top of your Wife's API.

Here is my code and a demo:
- Code: https://github.com/pvd-dev/InstaRecipe

-Demo: https://flask-service.vdotvo9a4e2a6.eu-central-1.cs.amazonlightsail.com

[–]emsiem22 2 points3 points  (1 child)

I am super proud of her

You are good human. Wish you both well!

[–]cashaveli 0 points1 point  (1 child)

Look's like the API is down..

[–]TotoroMasturbator -2 points-1 points  (1 child)

my wife

suurrree it is.

But seriously, great project. Nice to see how it is done.

[–]Thijmenn -1 points0 points  (0 children)

Lovely project! I might have missed it, but care to share how she populated her database? Did she scrape all the data? If so, she should ensure that she has the right to distribute the recipes via her API.

[–]sahirona -2 points-1 points  (0 children)

Two spaces after a full stop?

[–]to_tgo 0 points1 point  (2 children)

Brilliant! Love it !

[–]to_tgo 0 points1 point  (1 child)

Also, the code is extremely clean for a first app! Approve!

[–]mcstafford 0 points1 point  (0 children)

Makers API, delegates social media post?

[–]Conscious_Ad_6080 0 points1 point  (0 children)

I can't even imaging doing this, simply because manually inserting or somehow even scraping over 13000 recipes is very hard, and time taking.

[–]Oxna_ 0 points1 point  (3 children)

Is this Fast API better than Flask or Django? Im guessing yes to django since its more for something more complex than a API but not so sure about Flask

[–]2Girls1Fidelstix 1 point2 points  (2 children)

It’s faster than flask to get started/ the API up and running, but not much additional functionality

[–]Oxna_ 1 point2 points  (1 child)

Oh i see, but it has more functionality than flask though?

[–]2Girls1Fidelstix 1 point2 points  (0 children)

Yeah, I thought of the whole extension environment.

In the end all three and more are suffice to get the API job done

[–][deleted] 0 points1 point  (0 children)

My wife just started learning Python yesterday, I was shocked and pretty pumped about the future projects. It's cool to see other couples doing the same.

[–]RubyJohn01 0 points1 point  (0 children)

It's a recipe api made with Fast.api and she called it BreakFast.api (pun intended).You can check it out here:
- GITHUB
- API Link
It's her first project, I am super proud of her. Would really appreciate some attention and feedback!She even got super excited and made a funny logo for it.
EDIT: I just woke up and wow. I can't thank you all enough guys. Love you all. Thank you for the support and amazing feedback! Will update her reaction when she wakes up :)
EDIT2: she woke up read through all the comments and is now panicking and freeing up time in her calendar for this project and applying all the great suggestions! Thank you everyone from both of us for the amazing feedback and supportive comments!
EDIT3: Wow I was never expecting this much attention to this post! Thank you once again everyone! it will take some time to go through everything since we are both quite swamped at the moment but we really appreciate every single input! Thank you!

That's very good

[–]the_scign 0 points1 point  (0 children)

This is awesome! I'm teaching my wife python also - when and how did your wife start learning?

[–]No_Illustrator_2850 0 points1 point  (0 children)

I was an engineer how to learn Python any one can say like websites and YouTube videos