Detailed Notes
This video looks at one piece of our URL shortener solution. We have an API that we built and want to be able to provide documentation easily. We do this by embracing Swagger. This tutorial focuses on how to handle posting values to a call and using Chat GPT to assist you in coding.
You can find out more through our online classes at https://school.develpreneur.com and register for free. Registration will add you to our email list and you will periodically receive coupons for courses as well as notifications of the latest releases.
Transcript Text
[Music] well hello and welcome back we are continuing our shortener our URL shortner API series of tutorials and related questions we're talking about the uh documentation the Swagger using swagger with flask rest rest X and using that to generate our documentation now I sat around let's just say I ran into a bit of a blocker and the blocker was this post and this is what we're going to focus on this time is we're going to talk about really this this thing this call with the others uh when we looked at them am I running it yes I'm running it when we looked at the other calls for example the um git so the short and Git it has a URL so if we try it out we could give it a URL code I don't even know uh let me flip over to postman real quick [Music] and uh get and so uh this is what I want for the URL and if I come over here and give it this and execute then it's going to run this is the URL that sent across uh this is the response actually as it came oh I'm sorry here it is as it came back and I I had given it some sort of bad URL was the URL but there you go so there is from the shortened URL here we get this this is what the original one was now if we change that number to like a 12 I don't know how many we have here uh so that one was there that was a nice long one actually happens to be the Swagger documentation now the challenge becomes when we do the post it required a form and if you look back here if you go to the Post sorry if this isn't I don't know if I can blow this up real quick yeah we can blow this up a little bit and so you can read it a little better uh so for the post is this the post oh there we go shorty post then uh within here there was a body that we were sending it that was a form essentially it was a form with a URL field and then uh we give it a value normally what we're seeing like if we do the Git it was a query parameter string so it was just something we were tacking on at the end what I ran into and spent a good little time walking around circles on it was getting this to work so that I could treat this within the Swagger page as a form which would be here so if I want to shorten it now uh and I'll show you this in a minute so if I want to shorten um let me do like let me take this chat open ey this big chat GPT thing we'll put that there execute it and then it comes back and gives us oh this is something it said it cannot rep understand so I just blew it up somewhere let's try [Applause] this test.com switch index.html let's give it that oh and I ran into this again why did I run into this again because if I do it here it works fine okay so let's go back and look over here so the key here is uh that it you need to add an argument I went back and forth quite a bit on this as far as how to get it uh what its type is all that kind of stuff and when I started looking around there was 15 different ways that this had issues and um basically finally ended up jumping over into chat GPT and and I asked it I said hey um I said here I want to document a flask rest X API that receives form form variables and so I do that and uh if I go all the way down here and then it's going to give me some answers and this is one of those things using uh chat GPT to help you through some stuff so here we go uh this one is a model uh it sends a model across which I ended up having a lot of issues with that uh and then this one let's see here's a post so that was expect user model I want to do it with a let me change that question a little bit document that receives a a form variable it's actually should be how to let's see what it gives us here um let's do it this way whop with ADD argument how to document that add argument and here we go this is the one we want I believe yeah so we have a required parser so let's do expand on four so here we [Music] go and this should hopefully give us what we need so if we come into here and we look at this let's make sure sure we got that and so if we look we have up here oh we don't have request parser so then we can do that which we're going to do let's do that here and so this is just going to be the parser I assume let's make sure that's right come in here and then we should be okay let's see if this works this one of those things that it worked and now that I'm looking at this it is not because it hates me so let stupid parser add argument I do it that way now let's take a look at it so let's go back out of here go back over here and if we look at the post shorten we're going to try it out we're going to give it a URL we'll just give it this URL execute browser or proxy Center requested the server could not understand probably because it doesn't like it in the Json so let's go back here let's go back to our earlier how to if we look all the way at the top let's look at that real quick okay so does that so if we do just that but I think that's going to be a problem yeah so that's the prams we don't want the pams we actually want it because we had our prams for our URL but we don't want a pram we actually want a form and there it is oh maybe we can do it this way let's try that so let's see uh here we do whoops we do that and it's going to be uh URL enter the URL that to convert and then uh within this we're just going to do that okay request form let's try that that get let's try that let's see if it works so it thinks it works there and and post try it out let's just do that execute it success okay so this comes through and it gave us that now let's see if we run post and it works yay we finally got it working and it was all mostly to the help of chat GPT which is what I wanted to sort of throw in here uh besides the fact that we have our our post now working and so all of our others will work as well and it was a pain in the butt to do that because it's a slightly different one so again um let's just do like get hello that doesn't even need any if I try it out boom API is up if I do um well that one that was just a test one so if we did get shorten and we give it oh let's try it out and let's give it some value out of the um nope that's the post I don't want the post I want the don't save it uh get there I've send that across this one comes through because it comes as a parameter and boom we get our address back so there you go a little bonus of just we're really just focusing on documenting the post and using chat GPT we're going to come back we will wrap this one up we're going to talk about a few more things we can do some ways to tweak our comments a little bit more and wrap up this little mini Swagger Series so go out and have yourself a great day and we will talk to you next time hello this is Rob with develop or also known as building better developers wanted to announce that we have school. developer.com feel free to check it out if you like any of this information any of the content that we've sent and you would like to see more you can come out you can enroll for free we have free courses we've got places for you to get better at just learning a technology how how- toos you can work on your business skills we can help you with becoming a better developer as in coding and things like that a lot of the stuff you've seen on YouTube we also have out at school. develop andur we just have it a little more of a uh educational format and a way for you to track your progress as you move forward becoming a better developer
Transcript Segments
[Music]
well hello and welcome back we are
continuing our shortener our URL
shortner API series of tutorials and
related questions we're talking about
the uh documentation the Swagger using
swagger with flask rest rest X and using
that to generate our documentation now I
sat
around let's just say I ran into a bit
of a blocker and the blocker was this
post and this is what we're going to
focus on this time is we're going to
talk about really this this thing this
call with the others uh when we looked
at them am I running it yes I'm running
it when we looked at the other
calls for example the um
git so the short and Git it has a URL so
if we try it out we could give it a URL
code I don't even know uh let me flip
over to postman real
quick
[Music]
and uh
get and so uh this is what I want for
the
URL and if I come over here and give it
this and execute then it's going to run
this is the URL that sent across uh this
is the response actually as it came oh
I'm sorry here it is as it came back and
I I had given it some sort of bad URL
was the URL but there you go so there is
from the shortened URL
here we get this this is what the
original one was now if we change that
number to like a 12 I don't know how
many we have here uh so that one was
there that was a nice long
one actually happens to be the Swagger
documentation now the challenge
becomes when we do the
post it required a
form and if you look back here if you go
to the
Post sorry if this isn't I don't know if
I can blow this up real quick yeah we
can blow this up a little bit and so you
can read it a little
better uh so for the post is this the
post oh there we go shorty post then uh
within here there was a body that we
were sending it that was a form
essentially it was a form with a URL
field and then uh we give it a value
normally what we're seeing like if we do
the Git it was a query parameter string
so it was just something we were tacking
on at the end what I ran into and spent
a good little time walking around
circles on it was getting this to work
so that I could treat this within the
Swagger page as a form which would be
here so if I want to shorten it now uh
and I'll show you this in a minute so if
I want to shorten
um let me do like let me take this chat
open ey this big chat GPT thing we'll
put that there execute it and then it
comes back and gives us oh this is
something it said it cannot rep
understand so I just blew it up
somewhere let's try
[Applause]
this
test.com switch index.html let's give it
that oh and I ran into this again why
did I run into this
again because if I do it
here it works
fine okay
so let's go back and look over here so
the key here
is uh that it you need to add an
argument I went back and forth quite a
bit on this as far as how to get it uh
what its type is all that kind of stuff
and when I started looking around there
was 15 different ways that this had
issues and um basically finally ended up
jumping over into chat
GPT and and I asked it I said
hey
um I said here I want to
document a flask rest X API that
receives form form variables and so I do
that and uh if I go all the way down
here and then it's going to give me some
answers and this is one of those things
using uh chat GPT to help you through
some
stuff so here we go uh this one is a
model uh it sends a model
across which I ended up having a lot of
issues with
that uh and then this one let's
see here's a
post so that was expect user model I
want to do it with a let me change that
question a little
bit document that receives
a a form
variable it's actually should be how
to let's see what it gives us
here um let's do it this way
whop with ADD
argument
how to document
that add
argument and here we go this is the one
we
want I
believe yeah so we have a required
parser
so let's do expand on
four so here we
[Music]
go and this should hopefully give us
what we need so if we come into here and
we look at this let's make sure sure we
got
that and so if we look we have up here
oh we don't have request
parser so
then we can do
that which we're going to
do let's do that
here and so this is just going to be the
parser I
assume
let's make sure that's right come in
here and
then we should be okay let's see if this
works this one of those things that it
worked and now that I'm looking at this
it is not because it hates me so let
stupid
parser add argument I do it that
way now let's take a look at it so let's
go back out of
here go back over
here and if we look at the post
shorten we're going to try it out we're
going to give it a URL we'll just give
it this
URL
execute
browser or proxy Center requested the
server could not understand probably
because it doesn't like it in the
Json so let's go back
here let's go back to our earlier how
to if we look all the way at the top
let's look at that real
quick okay so does
that so if we do
just that but I think that's going to
be a problem yeah so that's the prams we
don't want the pams we actually want
it because we had our prams for our URL
but we don't want a pram we actually
want a
form and there it
is oh maybe we can do it this
way let's try that so let's
see uh here we do whoops we do
that and it's going to be
uh
URL enter the URL that to
convert and
then uh within
this
we're just going to do
that okay request
form let's try that that
get let's try
that let's see if it
works so it thinks it works
there and and
post try it
out let's just do that execute
it success okay so this comes through
and it gave us that now let's see if we
run
post and it works yay we finally got it
working and it was all mostly to the
help of chat GPT which is what I wanted
to sort of throw in here uh besides the
fact that we have
our our post now working and so all of
our others will work as well and it was
a pain in the butt to do that because
it's a slightly different one so again
um let's just do like get hello that
doesn't even need any if I try it out
boom API is up if I do um well that one
that was just a test one so if we did
get
shorten and we give it
oh let's try it out and let's give it
some value out of
the um nope that's the post I don't want
the post I want the don't save it uh
get
there I've send that across this one
comes through because it comes as a
parameter and boom we get our address
back so there you go a little bonus of
just we're really just focusing on
documenting the post and using chat GPT
we're going to come back we will wrap
this one up we're going to talk about a
few more things we can do some ways to
tweak our comments a little bit more and
wrap up this little mini Swagger Series
so go out and have yourself a great day
and we will talk to you next
time hello this is Rob with develop or
also known as building better developers
wanted to announce that we have school.
developer.com feel free to check it out
if you like any of this information any
of the content that we've sent and you
would like to see more you can come out
you can enroll for free we have free
courses we've got places for you to get
better at just learning a technology how
how- toos you can work on your business
skills we can help you with becoming a
better developer as in coding and things
like that a lot of the stuff you've seen
on YouTube we also have out at school.
develop andur we just have it a little
more of a uh educational format and a
way for you to track your progress as
you move forward becoming a better
developer