-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
9 changed files
with
3,125 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 |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
|
||
.terraform.lock.hcl | ||
|
||
# Serverless framework | ||
node_modules/ |
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
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,22 @@ | ||
# Python Hello World | ||
|
||
This demonstrates a simple example of running a [Flask](https://flask.palletsprojects.com/en/2.0.x/quickstart/) HTTP server in a [Scaleway Serverless Container](https://www.scaleway.com/en/serverless-containers/). | ||
|
||
## Requirements | ||
|
||
This example assumes you are familiar with how Serverless Containers work. If needed, you can | ||
check the [Scaleway official documentation](https://www.scaleway.com/en/docs/serverless/containers/quickstart/). | ||
|
||
This example uses the Scaleway Serverless Framework Plugin. Please set up your environment with the requirements stated in the [Scaleway Serverless Framework Plugin](https://github.com/scaleway/serverless-scaleway-functions) before trying out the example. | ||
|
||
## Deployment | ||
|
||
Once your environment is set up, you can deploy your container with: | ||
|
||
```sh | ||
npm i | ||
|
||
serverless deploy | ||
``` | ||
|
||
When the deployment is complete, you should be able to `curl` the container's endpoint or hit it from a browser and see the message returned by the Flask server. |
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,10 @@ | ||
FROM python:3.10 | ||
WORKDIR /app | ||
|
||
RUN pip3 install --upgrade pip | ||
COPY requirements.txt . | ||
RUN pip3 install -r requirements.txt --target . | ||
|
||
COPY handler.py . | ||
|
||
CMD [ "python3", "./handler.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,15 @@ | ||
from flask import Flask | ||
import os | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/") | ||
def hello(): | ||
return "Hello world from the Python container!" | ||
|
||
|
||
if __name__ == "__main__": | ||
port_env = os.getenv("PORT", 8080) | ||
port = int(port_env) | ||
app.run(debug=True, host="0.0.0.0", port=port) |
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 @@ | ||
Flask==3.0.0 |
Oops, something went wrong.