-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1615101
Showing
9 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Imagine this file as a recipe for setting up a virtual computer. | ||
|
||
# Dockerfiles typically start with a 'base image'. There are loads of these | ||
# and you can find them at hub.docker.com. | ||
# We're going to use a base image for Python veresion 3.11 | ||
FROM python:3.11 | ||
|
||
# This base image contains essentially everything necessary for a 'virtual | ||
# computer'. It has a terminal, certain basic commands, and of course Python. | ||
|
||
# We run a command to install `pipenv` | ||
RUN pip install pipenv | ||
|
||
# We'll need our app's files in the container in order to be able to run them! | ||
# We copy them in from the current directory to the folder `/app` in | ||
# our virtual computer. Reminder `.` means 'the current directory' | ||
COPY . /app | ||
|
||
# We set the working directory for commands from this point on | ||
WORKDIR /app | ||
|
||
# We run `pipenv install` to install our project's dependencies. Since we've | ||
# copied in our `Pipfile`, `pipenv` will use that to get a list of dependencies. | ||
# We include a couple of extra options suitable for deployment. | ||
RUN pipenv install --system --deploy | ||
|
||
# At this point we've set up our virtual computer, but we've not _yet_ run our | ||
# application. And we're not going to! We're just setting up the container | ||
# so that it's ready to do so when we tell it. | ||
|
||
# So we're going to tell Docker here that when we _do_ want to run it, this is | ||
# what it should run: | ||
CMD ["python", "app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
pytest = "*" | ||
flask = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.11" | ||
python_full_version = "3.11.0" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Simple Server | ||
|
||
This is a simple web server that serves a single route. | ||
|
||
To set up this project. | ||
|
||
```bash | ||
; pipenv install | ||
; pipenv shell | ||
; pytest # Run the tests | ||
; python app.py # Run the server | ||
``` | ||
|
||
|
||
<!-- BEGIN GENERATED SECTION DO NOT EDIT --> | ||
|
||
--- | ||
|
||
**How was this resource?** | ||
[😫](https://airtable.com/shrUJ3t7KLMqVRFKR?prefill_Repository=makersacademy%2Fcloud-deployment&prefill_File=codebases%2Fsimple_server%2FREADME.md&prefill_Sentiment=😫) [😕](https://airtable.com/shrUJ3t7KLMqVRFKR?prefill_Repository=makersacademy%2Fcloud-deployment&prefill_File=codebases%2Fsimple_server%2FREADME.md&prefill_Sentiment=😕) [😐](https://airtable.com/shrUJ3t7KLMqVRFKR?prefill_Repository=makersacademy%2Fcloud-deployment&prefill_File=codebases%2Fsimple_server%2FREADME.md&prefill_Sentiment=😐) [🙂](https://airtable.com/shrUJ3t7KLMqVRFKR?prefill_Repository=makersacademy%2Fcloud-deployment&prefill_File=codebases%2Fsimple_server%2FREADME.md&prefill_Sentiment=🙂) [😀](https://airtable.com/shrUJ3t7KLMqVRFKR?prefill_Repository=makersacademy%2Fcloud-deployment&prefill_File=codebases%2Fsimple_server%2FREADME.md&prefill_Sentiment=😀) | ||
Click an emoji to tell us. | ||
|
||
<!-- END GENERATED SECTION DO NOT EDIT --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
from flask import Flask, request | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/', methods=['GET']) | ||
def get_home(): | ||
return "Hello, world!" | ||
|
||
if __name__ == '__main__': | ||
app.run( | ||
debug=True, | ||
host="0.0.0.0" # Listen for connections _to_ any server | ||
) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
from app import app | ||
|
||
@pytest.fixture | ||
def web_client(): | ||
app.config['TESTING'] = True | ||
with app.test_client() as client: | ||
yield client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def test_get_home(web_client): | ||
response = web_client.get("/") | ||
assert response.status_code == 200 | ||
assert response.data.decode("utf-8") == "Hello, world!" |