#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: Getting started: Program structures
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Alright, so let's get our project ready and everything set up here. So I'm over here in the GitHub repository and Day 97 to 99 in the demo app.
0:13
So, what I want to do is just create a virtual environment and then we'll do the rest from within PyCharm. Okay, so we can just open this folder
0:23
on Windows you would type "start." on Mac you type "open". So here we have our empty app and we've done this many, many times throughout this course
0:37
but this time is different. We want to actually have two separate applications contained within this project.
0:44
Let's go and create a folder for the client and let's create a folder for the web. Alright, so there's our client, there's our web,
0:55
each one of these is going to have it's own set of requirements, so let's go ahead and add those. Okay, this is a pretty good start.
1:09
So we have our set of requirements for a client and we have the set of requirements for the web. And notice we have our virtual environment active here
1:18
and if we ask what is installed, there's nothing, of course. So we're going to entirely focus on the beginning. Just on the web application, okay?
1:29
So we're going to close up this client here but before we do there's one really quick thing we should do. When we have files over here,
1:36
we kind of want to treat this as the whole project, right? You might have a api.py and a program.py and the program might import api.
1:44
In order for that to work easily in PyCharm is what we need to mark this directory as the source's root, say this is kind of its own little area.
1:51
Same thing for web. It's effectively adding that thing to the Python path and making that the working directory and things like that.
2:01
Okay, so, this is just the basic stuff that we've got going on here. Alright, that's the web one. We're going to tell the web one
2:09
that we require Flask and SQLAlchemy. Those are the things that we're going to need. So, we'll go over here to web. pip install -r requirements.txt
2:21
install everything in that file. And last thing, let's go ahead and add an app.py this is pretty standard in Flask
2:33
and we'll just print Flask coming soon. And let's go ahead and run this. Yay, Flask is coming soon. Let's get this run configuration set up
2:44
for a few good things here. So we'll go over here and say this is going to be the web app. And we also want to have it restart
2:52
because the web apps open a port, this one will be port 5000 and if you try to run a second one without closing this one it'll crash,
2:59
so this will tell PyCharm obviously to do that correctly. Alright, well, I think our structure is in place.