Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alisdairbr authored and edouardb committed Feb 20, 2023
0 parents commit 5b76176
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: uvicorn main:app --port ${PORT:-8000} --host 0.0.0.0
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<div align="center">
<a href="https://koyeb.com">
<img src="https://www.koyeb.com/static/images/icons/koyeb.svg" alt="Logo" width="80" height="80">
</a>
<h3 align="center">Koyeb Serverless Platform</h3>
<p align="center">
Deploy a Python FastAPI application on Koyeb
<br />
<a href="https://koyeb.com">Learn more about Koyeb</a>
·
<a href="https://koyeb.com/docs">Explore the documentation</a>
·
<a href="https://koyeb.com/tutorials">Discover our tutorials</a>
</p>
</div>

## About Koyeb and the Python FastAPI example application

Koyeb is a developer-friendly serverless platform to deploy apps globally. No-ops, servers, or infrastructure management.
This repository contains a Python FastAPI application you can deploy on the Koyeb serverless platform for testing.

This example application is designed to show how a Python FastAPI application can be deployed on Koyeb.

## Getting Started

Follow the steps below to deploy and run the Python FastAPI application on your Koyeb account.

### Requirements

You need a Koyeb account to successfully deploy and run this application. If you don't already have an account, you can sign-up for free [here](https://app.koyeb.com/auth/signup).

### Deploy using the Koyeb button

The fastest way to deploy the Python FastAPI application is to click the **Deploy to Koyeb** button below.

[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/koyeb/example-fastapi&branch=main&name=fastapi-on-koyeb)

Clicking on this button brings you to the Koyeb App creation page with everything pre-set to launch this application.

_To modify this application example, you will need to fork this repository. Checkout the [fork and deploy](#fork-and-deploy-to-koyeb) instructions._

### Fork and deploy to Koyeb

If you want to customize and enhance this application, you need to fork this repository.

If you used the **Deploy to Koyeb** button, you can simply link your service to your forked repository to be able to push changes.
Alternatively, you can manually create the application as described below.

On the [Koyeb Control Panel](//app.koyeb.com/apps), click the **Create App** button to go to the App creation page.

1. Select `GitHub` as the deployment method to use
2. In the repositories list, select the repository you just forked
3. Specify the branch to deploy, in this case `main`
4. Then, give your service a name, i.e `fastapi-on-koyeb`
5. Click **Deploy**

You land on the deployment page where you can follow the build of your FastAPI application. Once the build has completed, your application is deployed and you will be able to access it via `<YOUR_APP_NAME>-<YOUR_ORG_NAME>.koyeb.app`.

## Contributing

If you have any questions, ideas or suggestions regarding this application sample, feel free to open an [issue](//github.com//koyeb/example-fastapi/issues) or fork this repository and open a [pull request](//github.com/koyeb/example-fastapi/pulls).

## Contact

[Koyeb](https://www.koyeb.com) - [@gokoyeb](https://twitter.com/gokoyeb) - [Slack](http://slack.koyeb.com/) - [Community](https://community.koyeb.com/)
17 changes: 17 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}


16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
anyio==3.6.2
click==8.1.3
fastapi==0.92.0
h11==0.14.0
httptools==0.5.0
idna==3.4
pydantic==1.10.5
python-dotenv==0.21.1
PyYAML==6.0
sniffio==1.3.0
starlette==0.25.0
typing_extensions==4.5.0
uvicorn==0.20.0
uvloop==0.17.0
watchfiles==0.18.1
websockets==10.4

0 comments on commit 5b76176

Please sign in to comment.