📺 Develpreneur YouTube Episode

Video + transcript

How Do I Use Flask To Create an API With Python?

2023-07-27 •Youtube

Detailed Notes

Python is a powerful and general purpose language. You can add the Flask library to quickly do a large number of tasks. That include spinning up an API with a few lines of code. This episode walks through exactly that.

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
foreign
[Music]
well hello and welcome back we are
continuing in a sense although this is
we're going to focus on one specific
question we're going to talk about
basically sort of what is flask and then
how do I create an API using flask in
Python
and we're going to look at these two but
this is part of a larger project that
we're working on
we're working on our way through
building what we call Shorty which is
just a not terribly unique or creative
way name I guess for a URL shortener
much like you would see bit.ly or owl.ly
or one of those and we've worked our way
through a couple of pieces but now we're
going to work on the API side of it
because we're going to have to be able
to take a request and return back a
short a shortened one a shortened URL
and of course we need to do that through
an API the way we're going to do that
I guess it says of course but that's how
we're going to do it so we're going to
use this thing called flask and if you
haven't used it check out flask if you
just go to
flash.palletsprojects.com or if you go
to Google and you just do something
along the lines of uh let's see python
flask
search for that and you're going to get
some stuff here you can jump right into
it it's very useful
and we're just going to touch on it
actually if you look down the side here
there's a lot of things that are
available but we're going to do the most
the most simple which actually we're
going to start with their hello colorful
world
and we're gonna come in here we're going
to create a little file
a new file and this will be we're going
to call this API py
and we're just going to start with
something very simple so what we do need
to do is we need to make sure that we've
installed flask
if I have oh apparently I hadn't so here
we go so now I should be able to do here
now what you would normally do is you do
Python 3 API let's see what that does
so it doesn't really do anything oh
because we don't have it actually doing
anything
but what you do need to do is if we do a
flask run
then it's going to tell us
we can't locate a flask application and
so what we're going to see here is okay
we've got this little thing
and there we go so we're going to have
to tell it what our app is
now our app in this case so if we do
theirs if we say Flash the dashes dashes
app hello run guess what
doesn't exist but if we do API
uh oh sorry
not run if we change that to API because
that's going to be the name of this
boom python thing so now we've got this
running at
127.001 5000.
so what we want to do let's background
that
and then if we do curl
that guy HTTP because this is going to
be a very simple way to test our call
uh one on five thousand
well
I want to do a dash get
I think that's how I do it
okay actually what I had to do is
because I had my app actually paused
what I do want to do is then if I do
curl HTTP colon backslash whoops with
one of these
uh
127.001 5000.
there we go
so I get hello world and you notice that
I've even got it wrapped in this thing
so I get a very straightforward result
coming from it which means
if I come back over here I can go and
actually I guess I ran where it was
there we go oh
there I can actually
here
I can come in and I can tell it what
port to run on
which it's going to tell us like your
dash host
could do dash dash host and I think it's
just a equals
so I'm gonna do
127.001 then I'm going to run it on
let's run it on Port 6500.
boom and then if I come over here
oh we'll come back around to that
because one of the first things I want
to do is let's go ahead and we're going
to pull in
this
probably because we're going to need it
yeah we'll go ahead and do it because
we're gonna end up using this
um so I'm going to escape
and we can always do so what we're going
to do here
so we're going to create a different
endpoint so this will be
we're just going to call this shorten
we're going to start with this
and call shorten
and then he's going to return
so let's go look at the first thing
we've got here
is what we want to be able to do
is we want to be able to give it a
parameter
and so let's do here let's call this URL
which I believe is how it's done oh
actually I think it's just here so I'm
going to do it shortened URL
because I think that's how it looks
and if we come in
oh yeah it is so if we do shorten
so now what we can do
is we take this whoops uh we'll do slash
so if we're going to do this we're going
to do that we're going to sorry if we if
we call short and Slash and then the
name of a URL
and then we send the URL we're going to
send that URL in and then we're going to
return let's say
um
we're just going to say this is
what you sent
and we're going to do
uh Escape
just to be safe
URL
and so if you look here
what we're going to do is
Escape that name out and then that means
if we do something like weird like this
it's still going to come through so if
we send it tags and stuff like that uh
did I get it all right I did so now
let's just go back to run it
let's run five thousand if I do my
initial one oh
a port
and then what I get is hello world but
if I do shorten
now I'm going to get that it's not found
because I can't
I did not provide a name if I do this
and I do
um
to be colon backslash
some long
url.com
slash a equals one
uh let's see I'm sorry that's not a real
one but we're gonna do it anyways
b equals two so now we've got this big
old thing
if we do that
because of the slashes it's going to
give us some issues
so
we could get rid of this
oh it's still not going to give it to us
let's go back and look at our over here
so we have shortening URL so let's go
look at what our example was here
they said
that if we do slash name and we give it
a name then that will pick that up so if
we just do a simple URL then that should
be
let's just do this
there we go
and so when we do oh it's because it has
ah
because we have parameters there okay
so right now we've already found in
we're running a little bit of an issue
with our apis we've got to be able to
figure out a way to send an actual
an actual URL as opposed to something
just very simple so here if we did
something url.com and then we did let's
do
just to show you what the tags are
I don't really we'll need it but we're
going to do it anyways
um
there's a parse error
uh
well it doesn't like that very much
anyways okay
so I'm not sure that our Escape is going
to help us very much in this one let's
go back and look at that just in case
because that should be
escaping because we're entered as text
rather than that so if I did this
is what they're saying
oh because it's formatting it okay
let's see
let's just do exactly their example
yeah so we get an issue with that is it
doesn't like what we're sending
but if we do this
because we're doing a format uh come
here
so let's just do this
let's do what they said
so I can show you this and really it's
just to do it
you set this
now we need to reload it
I'm assuming
and so now if we do it nope it still
doesn't sound like it so we've got
something in our
oh it's because of our slashes Ah that's
our problem
yeah it doesn't like that
at all in here because we would need to
probably let's go back to this if we do
this
and this will this give us what I need
nope then it gives us a we're not found
because we didn't actually get the thing
so
we're going to play around with this
first
is within our API
what we want to be able to do
is let's just do this we don't need to
escape it right now
what we want to be able to do is do is
send a URL in of some sort and then do
something with it so
so let's do
this because we're going to actually
step up a little bit because that was
just a straight out we're going to get
something but here we're going to get
some and such because this is going to
be important when we get into those so
we get into the API because what we're
going to end up doing
is we're going to be able to we're going
to want to be able to do a get
and we're going to be able to do a post
so actually we're going to do is we're
going to post to shorten and we'll deal
with this a little later
and then there's going to be a different
one that is going to be the get
I'm putting these in place these are
placeholders we'll come back to them uh
here let's see so it's like that so now
if we do a get
uh oh I need it to be here
so if I do this I should get the same
thing because I'm still doing a get when
I do the this by default when I do this
curl that's going to be a get
and let me just go back to the one that
was simpler there we go some long URL
but this is what you sent okay
so we're doing working on our git first
this is going to be essentially what
we're going to do is this going to be
instead of shorten this is going to be
well we can call it shortened we're just
gonna it's the same name here but here
we're going when we do a get then the
URL we send is we're going to send
something back this so it'll be uh
actually let's do
turn value
and the first thing is going to be this
is what you sent
and then we're going to do return value
Plus
equals and we're going to return return
value
and then it will be something that's
going to be
is
the actual
URL
and we're just going to call this result
and we're just going to say for right
now result
equals
do it like this way assume we did
something
so what you're probably going to end up
here
would be our short URL
which we can we can either do it with an
HTTP or not but let's see so if we do
here
so we'll assume that we don't have the
HTTP on it because it which would really
make sense so now it's going to be like
my short
dot com but then we're still going to
have that slash so that's something
we're going to have to worry about
so I think we did it that way how did we
do it oh we haven't really
looked at that yet so
it's probably going to end up being this
it's going to be four five something
like this is what we're going to want to
send but we're going to need to be able
to wrap that and so we're going to have
to be able to get either
we're going to end this is two things we
can either send straight code in
which is this which is probably where
we're gonna we're going to want to do
is say
although we're probably gonna have to
clean it too so we'll start with this
so we're going to start with is we're
going to send them some code
and then it's going to get back the you
know the shortened URL
and let's just do this uh
uh we'll put a little Line Feed in there
just because
not that one that one
run it
go over here boom okay so now we got
something a little easier but now what
we're going to do and you can see all
this stuff as I mentioned in here so if
you want to build something when we're
complicated then you can see things like
hey you know what is the what's the
method uh which problem
that is probably what we're going to
want to do
since it's the same one
I'm going to do this whoop
actually let's just do get
comma
[Music]
any post
and here we're going to say let's do
this
if it's post
else because it's going to be a get so
that's a get here
return value equals
not implemented yet
oh which we need to get the request is
going to have to come in
oh I think it's automatically gonna do
that oh we need to I'm sorry we have to
import that's right
so that means we also have to import the
request from flask
now that will come through
let's go ahead and show you what that
looks like so
believe
it's as simple as I think it's Dash get
okay so just to save you a little bit of
time you may have noticed a little jump
there
and what I did is I want to do X and I
put its post
there we go
uh and then I've got my little percent
after that I'm not sure why I get that
but anyways
so we get that so that allows me to post
if I do a get
and then
we're here
and now let's go back and look over one
of the things we can do
is we can send parameters
and so that's what I want to take a look
at
and again
if you want to look in here running
Direction URL building
probably what we want
here we go request data
maybe nope that's not what we want
so we go here
oh here we go
foreign
so here
let's see exchange blah blah blah that's
how I want to do oh that's if I want to
rebuild something
I'm going to do a template I can render
a template I don't really need that
right now
here we go
so I can do
that's in a post
and
let's do it this way we're going to play
with it for a second because we can so
let's come in here
I do login
nope I don't need longer that's their
thing that's totally useless to me
instead of this
I do shorten
and then I'm going to do print
request
let's try that
um
and so let's save that
I may have time jumped you a little bit
but it's because I needed to wrap my URL
in quotes as far as using curl so now if
I do it uh and I want to just let me
clean this up a tad because I want to
give something whoops
um
let me run it
unexpected event where did I oh shoot
got a space in there somewhere
there we go so now if I run it
I get success because that's what I kick
back but you can see here where I pulled
those suckers off so now
if I go back to shorten then that should
have been fine so let's get rid of that
so now
if I go back to shorten
let's go all the way back
uh
if we go back to here the one we did all
the way here we go big long URL
that's we're going to do URL equals
uh we have to just wrap this
and then we come all the way back here
there we go and now this is what you
sent so we did something but notice that
it actually let's see what did it get
oh because I see this is where we're
going to run into some issues this will
be a little bit of a challenge we're
going to want to put we're going to want
to post this
because if we wrap it into the string
then we're going to end up with some
issues so we're going to be having to
either
oh which we won't have to do this would
actually never exist I'm sorry because
what's going to happen is what we would
normally do is for this for the
shortened
we're going to post
uh so we hit a colon backlash slash
short name
some number there okay so it's going to
come through
and so now
we have a an API and I think I'm going
to hold here
because what we've done is we do have
creating an API using python because we
can use this using our flask run
and we have our uh we're using it in
flask as well
so we do have a little bit of testing an
API call but I want to talk next time
we're going to come back and we'll go a
little more deeper into this now that we
have this out here and find some easier
ways than what I just went through with
curl as you can see is a little bit of a
pain and we're going to check this thing
out called Postman
that being said get back to your day
hope you have a good one and we'll talk
to you next time around
hello this is Rob with developmentor
also known as building better developers
wanted to announce that we have
school.developmentor.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 our how to's you
can work on your business skills we can
help you with becoming a better
developer as encoding and things like
that a lot of the stuff you've seen on
YouTube we also have out at
school.development or we just have it a
little more of a educational format and
a way for you to track your progress as
you move forward becoming a better
developer
foreign
Transcript Segments
0.42

foreign

18.89

[Music]

27.119

well hello and welcome back we are

30

continuing in a sense although this is

32.759

we're going to focus on one specific

34.14

question we're going to talk about

35.6

basically sort of what is flask and then

37.98

how do I create an API using flask in

40.559

Python

41.76

and we're going to look at these two but

43.32

this is part of a larger project that

45.84

we're working on

47.16

we're working on our way through

48.36

building what we call Shorty which is

51.18

just a not terribly unique or creative

55.379

way name I guess for a URL shortener

58.5

much like you would see bit.ly or owl.ly

61.86

or one of those and we've worked our way

64.26

through a couple of pieces but now we're

65.7

going to work on the API side of it

67.619

because we're going to have to be able

68.82

to take a request and return back a

73.439

short a shortened one a shortened URL

75.72

and of course we need to do that through

77.58

an API the way we're going to do that

80.52

I guess it says of course but that's how

82.619

we're going to do it so we're going to

84.24

use this thing called flask and if you

86.759

haven't used it check out flask if you

89.34

just go to

91.04

flash.palletsprojects.com or if you go

93.96

to Google and you just do something

96.18

along the lines of uh let's see python

100.079

flask

102.36

search for that and you're going to get

104.46

some stuff here you can jump right into

106.439

it it's very useful

108.78

and we're just going to touch on it

110.34

actually if you look down the side here

111.96

there's a lot of things that are

114.299

available but we're going to do the most

116.34

the most simple which actually we're

118.56

going to start with their hello colorful

120.659

world

121.619

and we're gonna come in here we're going

122.939

to create a little file

125.04

a new file and this will be we're going

128.16

to call this API py

133.26

and we're just going to start with

134.94

something very simple so what we do need

136.8

to do is we need to make sure that we've

138.54

installed flask

143.94

if I have oh apparently I hadn't so here

146.34

we go so now I should be able to do here

150.239

now what you would normally do is you do

151.68

Python 3 API let's see what that does

155.58

so it doesn't really do anything oh

157.56

because we don't have it actually doing

160.26

anything

161.16

but what you do need to do is if we do a

163.26

flask run

165.72

then it's going to tell us

167.819

we can't locate a flask application and

170.879

so what we're going to see here is okay

173.76

we've got this little thing

176.7

and there we go so we're going to have

178.14

to tell it what our app is

181.319

now our app in this case so if we do

183.48

theirs if we say Flash the dashes dashes

187.319

app hello run guess what

190.08

doesn't exist but if we do API

196.44

uh oh sorry

199.379

not run if we change that to API because

202.2

that's going to be the name of this

204.18

boom python thing so now we've got this

206.879

running at

209.06

127.001 5000.

212.4

so what we want to do let's background

215.159

that

216.659

and then if we do curl

221.159

that guy HTTP because this is going to

224.099

be a very simple way to test our call

227.58

uh one on five thousand

233.519

well

235.14

I want to do a dash get

238.56

I think that's how I do it

240.799

okay actually what I had to do is

243

because I had my app actually paused

246.06

what I do want to do is then if I do

247.739

curl HTTP colon backslash whoops with

250.92

one of these

252.599

uh

254.48

127.001 5000.

258.12

there we go

259.38

so I get hello world and you notice that

261.66

I've even got it wrapped in this thing

263.4

so I get a very straightforward result

267.24

coming from it which means

270.3

if I come back over here I can go and

272.639

actually I guess I ran where it was

274.38

there we go oh

277.259

there I can actually

279.54

here

282.6

I can come in and I can tell it what

285.3

port to run on

287.04

which it's going to tell us like your

288.96

dash host

291.12

could do dash dash host and I think it's

294.24

just a equals

296.94

so I'm gonna do

298.639

127.001 then I'm going to run it on

301.32

let's run it on Port 6500.

306.06

boom and then if I come over here

313.139

oh we'll come back around to that

315.24

because one of the first things I want

316.08

to do is let's go ahead and we're going

318.72

to pull in

319.919

this

322.38

probably because we're going to need it

323.88

yeah we'll go ahead and do it because

325.199

we're gonna end up using this

327.539

um so I'm going to escape

330.6

and we can always do so what we're going

332.52

to do here

334.8

so we're going to create a different

335.82

endpoint so this will be

339.24

we're just going to call this shorten

341.699

we're going to start with this

345.9

and call shorten

350.1

and then he's going to return

354.18

so let's go look at the first thing

356.039

we've got here

358.199

is what we want to be able to do

361.38

is we want to be able to give it a

363.96

parameter

365.94

and so let's do here let's call this URL

370.44

which I believe is how it's done oh

371.94

actually I think it's just here so I'm

373.5

going to do it shortened URL

377.34

because I think that's how it looks

381.36

and if we come in

386.039

oh yeah it is so if we do shorten

389.16

so now what we can do

391.08

is we take this whoops uh we'll do slash

395.039

so if we're going to do this we're going

396.12

to do that we're going to sorry if we if

398.819

we call short and Slash and then the

400.44

name of a URL

402.72

and then we send the URL we're going to

404.58

send that URL in and then we're going to

406.86

return let's say

409.68

um

410.639

we're just going to say this is

412.8

what you sent

417

and we're going to do

419.699

uh Escape

422.34

just to be safe

424.319

URL

426.72

and so if you look here

428.94

what we're going to do is

431.94

Escape that name out and then that means

434.4

if we do something like weird like this

437.639

it's still going to come through so if

439.199

we send it tags and stuff like that uh

441.419

did I get it all right I did so now

444

let's just go back to run it

450.18

let's run five thousand if I do my

452.58

initial one oh

454.139

a port

457.44

and then what I get is hello world but

459.06

if I do shorten

462.66

now I'm going to get that it's not found

465

because I can't

466.8

I did not provide a name if I do this

470.46

and I do

472.259

um

473.22

to be colon backslash

476.099

some long

478.099

url.com

479.84

slash a equals one

483.539

uh let's see I'm sorry that's not a real

486.78

one but we're gonna do it anyways

489.24

b equals two so now we've got this big

491.099

old thing

492.84

if we do that

495.66

because of the slashes it's going to

497.699

give us some issues

499.259

so

501.599

we could get rid of this

505.74

oh it's still not going to give it to us

507.3

let's go back and look at our over here

510.84

so we have shortening URL so let's go

512.459

look at what our example was here

514.2

they said

516.959

that if we do slash name and we give it

519.599

a name then that will pick that up so if

522.959

we just do a simple URL then that should

524.94

be

528

let's just do this

532.2

there we go

534.24

and so when we do oh it's because it has

537.06

ah

539.1

because we have parameters there okay

542.279

so right now we've already found in

544.2

we're running a little bit of an issue

545.279

with our apis we've got to be able to

546.72

figure out a way to send an actual

550.74

an actual URL as opposed to something

553.86

just very simple so here if we did

556.5

something url.com and then we did let's

559.26

do

560.76

just to show you what the tags are

564.12

I don't really we'll need it but we're

565.5

going to do it anyways

569.04

um

569.58

there's a parse error

572.94

uh

578.04

well it doesn't like that very much

579.66

anyways okay

581.88

so I'm not sure that our Escape is going

583.62

to help us very much in this one let's

585.3

go back and look at that just in case

587.339

because that should be

591.3

escaping because we're entered as text

593.04

rather than that so if I did this

597.36

is what they're saying

603.66

oh because it's formatting it okay

609.6

let's see

611.1

let's just do exactly their example

614.82

yeah so we get an issue with that is it

616.92

doesn't like what we're sending

620.519

but if we do this

623.459

because we're doing a format uh come

626.519

here

630.66

so let's just do this

632.519

let's do what they said

634.92

so I can show you this and really it's

637.14

just to do it

642.36

you set this

651

now we need to reload it

654.3

I'm assuming

656.64

and so now if we do it nope it still

658.74

doesn't sound like it so we've got

659.94

something in our

664.8

oh it's because of our slashes Ah that's

667.8

our problem

671.88

yeah it doesn't like that

677.06

at all in here because we would need to

681.959

probably let's go back to this if we do

684.839

this

687

and this will this give us what I need

689.64

nope then it gives us a we're not found

691.74

because we didn't actually get the thing

693.66

so

694.92

we're going to play around with this

696.06

first

696.959

is within our API

700.74

what we want to be able to do

703.399

is let's just do this we don't need to

705.959

escape it right now

707.339

what we want to be able to do is do is

709.019

send a URL in of some sort and then do

712.98

something with it so

715.079

so let's do

717.24

this because we're going to actually

718.8

step up a little bit because that was

720.72

just a straight out we're going to get

722.1

something but here we're going to get

723.6

some and such because this is going to

725.76

be important when we get into those so

727.86

we get into the API because what we're

729.779

going to end up doing

732.18

is we're going to be able to we're going

734.459

to want to be able to do a get

736.8

and we're going to be able to do a post

738.3

so actually we're going to do is we're

739.56

going to post to shorten and we'll deal

742.2

with this a little later

743.88

and then there's going to be a different

745.019

one that is going to be the get

750.959

I'm putting these in place these are

752.459

placeholders we'll come back to them uh

754.68

here let's see so it's like that so now

757.26

if we do a get

761.24

uh oh I need it to be here

768.6

so if I do this I should get the same

770.519

thing because I'm still doing a get when

772.68

I do the this by default when I do this

775.86

curl that's going to be a get

777.6

and let me just go back to the one that

780.12

was simpler there we go some long URL

782.04

but this is what you sent okay

784.8

so we're doing working on our git first

786.839

this is going to be essentially what

789.779

we're going to do is this going to be

791.76

instead of shorten this is going to be

794.88

well we can call it shortened we're just

796.92

gonna it's the same name here but here

800.82

we're going when we do a get then the

803.279

URL we send is we're going to send

806.519

something back this so it'll be uh

809.399

actually let's do

811.32

turn value

813.6

and the first thing is going to be this

816.72

is what you sent

819.959

and then we're going to do return value

822.899

Plus

824.76

equals and we're going to return return

827.04

value

831

and then it will be something that's

832.56

going to be

840

is

841.2

the actual

843.36

URL

845.7

and we're just going to call this result

848.339

and we're just going to say for right

849.48

now result

851.279

equals

854.519

do it like this way assume we did

856.92

something

862.079

so what you're probably going to end up

863.339

here

865.079

would be our short URL

870.3

which we can we can either do it with an

873.06

HTTP or not but let's see so if we do

876.42

here

878.7

so we'll assume that we don't have the

880.32

HTTP on it because it which would really

882.6

make sense so now it's going to be like

883.98

my short

888.68

dot com but then we're still going to

890.76

have that slash so that's something

891.839

we're going to have to worry about

893.579

so I think we did it that way how did we

895.62

do it oh we haven't really

898.68

looked at that yet so

901.86

it's probably going to end up being this

903.12

it's going to be four five something

904.32

like this is what we're going to want to

906.06

send but we're going to need to be able

908.22

to wrap that and so we're going to have

909.66

to be able to get either

912.6

we're going to end this is two things we

915.36

can either send straight code in

919.019

which is this which is probably where

921.18

we're gonna we're going to want to do

923.94

is say

926.279

although we're probably gonna have to

927.48

clean it too so we'll start with this

931.32

so we're going to start with is we're

932.639

going to send them some code

934.32

and then it's going to get back the you

936.42

know the shortened URL

939.24

and let's just do this uh

943.92

uh we'll put a little Line Feed in there

945.54

just because

952.56

not that one that one

955.38

run it

956.88

go over here boom okay so now we got

959.22

something a little easier but now what

960.959

we're going to do and you can see all

962.76

this stuff as I mentioned in here so if

964.62

you want to build something when we're

965.94

complicated then you can see things like

968.339

hey you know what is the what's the

970.56

method uh which problem

973.74

that is probably what we're going to

975.18

want to do

977.22

since it's the same one

980.699

I'm going to do this whoop

984.3

actually let's just do get

986.76

comma

987.75

[Music]

989.639

any post

991.32

and here we're going to say let's do

994.019

this

998.639

if it's post

1001.1

else because it's going to be a get so

1003.98

that's a get here

1007.82

return value equals

1011.6

not implemented yet

1020.839

oh which we need to get the request is

1022.579

going to have to come in

1024.319

oh I think it's automatically gonna do

1026.059

that oh we need to I'm sorry we have to

1027.5

import that's right

1029.299

so that means we also have to import the

1031.76

request from flask

1035

now that will come through

1036.919

let's go ahead and show you what that

1038.48

looks like so

1042.919

believe

1045.62

it's as simple as I think it's Dash get

1050.72

okay so just to save you a little bit of

1053.66

time you may have noticed a little jump

1055.1

there

1056.24

and what I did is I want to do X and I

1058.88

put its post

1060.44

there we go

1062.059

uh and then I've got my little percent

1063.98

after that I'm not sure why I get that

1065.9

but anyways

1068.6

so we get that so that allows me to post

1071.539

if I do a get

1073.82

and then

1076.7

we're here

1078.08

and now let's go back and look over one

1080.6

of the things we can do

1082.76

is we can send parameters

1086.12

and so that's what I want to take a look

1087.74

at

1088.64

and again

1090.08

if you want to look in here running

1092.24

Direction URL building

1095.12

probably what we want

1098.48

here we go request data

1101.36

maybe nope that's not what we want

1108.44

so we go here

1120.559

oh here we go

1125.96

foreign

1129.98

so here

1133.52

let's see exchange blah blah blah that's

1136.58

how I want to do oh that's if I want to

1139.52

rebuild something

1146.419

I'm going to do a template I can render

1147.799

a template I don't really need that

1149.12

right now

1153.14

here we go

1155.059

so I can do

1158.299

that's in a post

1163.16

and

1165.74

let's do it this way we're going to play

1167.36

with it for a second because we can so

1169.82

let's come in here

1171.62

I do login

1173.6

nope I don't need longer that's their

1175.1

thing that's totally useless to me

1178.76

instead of this

1181.039

I do shorten

1186.14

and then I'm going to do print

1191.299

request

1194.419

let's try that

1196.94

um

1203.179

and so let's save that

1206.66

I may have time jumped you a little bit

1208.7

but it's because I needed to wrap my URL

1211.52

in quotes as far as using curl so now if

1215.299

I do it uh and I want to just let me

1218.24

clean this up a tad because I want to

1220.039

give something whoops

1222.98

um

1228.26

let me run it

1229.82

unexpected event where did I oh shoot

1233.66

got a space in there somewhere

1236.78

there we go so now if I run it

1239.539

I get success because that's what I kick

1241.52

back but you can see here where I pulled

1243.62

those suckers off so now

1246.32

if I go back to shorten then that should

1248.24

have been fine so let's get rid of that

1251.66

so now

1253.58

if I go back to shorten

1257.84

let's go all the way back

1261.679

uh

1268.76

if we go back to here the one we did all

1271.4

the way here we go big long URL

1275.36

that's we're going to do URL equals

1278.9

uh we have to just wrap this

1284

and then we come all the way back here

1290.659

there we go and now this is what you

1293.659

sent so we did something but notice that

1295.76

it actually let's see what did it get

1301.1

oh because I see this is where we're

1303.799

going to run into some issues this will

1305.059

be a little bit of a challenge we're

1306.14

going to want to put we're going to want

1307.34

to post this

1308.6

because if we wrap it into the string

1312.039

then we're going to end up with some

1314.539

issues so we're going to be having to

1316.58

either

1319.159

oh which we won't have to do this would

1320.9

actually never exist I'm sorry because

1322.64

what's going to happen is what we would

1324.44

normally do is for this for the

1327.02

shortened

1328.159

we're going to post

1330.26

uh so we hit a colon backlash slash

1332.74

short name

1335.38

some number there okay so it's going to

1338.299

come through

1339.799

and so now

1341.9

we have a an API and I think I'm going

1345.799

to hold here

1348.14

because what we've done is we do have

1350.659

creating an API using python because we

1353

can use this using our flask run

1355.4

and we have our uh we're using it in

1360.2

flask as well

1361.82

so we do have a little bit of testing an

1363.679

API call but I want to talk next time

1366.44

we're going to come back and we'll go a

1367.64

little more deeper into this now that we

1369.5

have this out here and find some easier

1371.72

ways than what I just went through with

1373.76

curl as you can see is a little bit of a

1375.62

pain and we're going to check this thing

1377.12

out called Postman

1378.62

that being said get back to your day

1381.08

hope you have a good one and we'll talk

1382.88

to you next time around

1383.96

hello this is Rob with developmentor

1386.299

also known as building better developers

1388.4

wanted to announce that we have

1390.82

school.developmentor.com feel free to

1393.02

check it out if you like any of this

1395.299

information any of the content that

1397.22

we've sent and you would like to see

1398.48

more you can come out you can enroll for

1400.52

free we have free courses we've got

1402.799

places for you to get better at just

1405.44

learning a technology our how to's you

1408.14

can work on your business skills we can

1410.179

help you with becoming a better

1411.62

developer as encoding and things like

1414.02

that a lot of the stuff you've seen on

1415.76

YouTube we also have out at

1417.88

school.development or we just have it a

1420.14

little more of a educational format and

1422.72

a way for you to track your progress as

1425.179

you move forward becoming a better

1427.34

developer

1428.9

foreign