Giter VIP home page Giter VIP logo

fastfly's Introduction

Deploy FastAPI on Render

References

Create Environment

WSL

$ conda create -n fastfly python=3.10
$ conda activate fastfly
$ pip install "fastapi[all]"
$ pip install SQLAlchemy
$ pip install psycopg2-binary
$ pip install asyncpg

$ uvicorn main:app --reload

Insert items

$ curl -X POST localhost:8000/items \
-H "Content-Type: application/json" \
-d '{"id": 1, "name": "Milk", "price": 2000, "description": "Nice milk", "on_offer": true}'

$ curl -X POST https://fastfly.onrender.com/items \
-H "Content-Type: application/json" \
-d '{"id": 1, "name": "Milk", "price": 2000, "description": "Nice milk", "on_offer": true}'
$ curl -X POST localhost:8000/items \
-H "Content-Type: application/json" \
-d '{"id": 2, "name": "Coffee", "price": 5000, "description": "Nice coffee", "on_offer": false}'

List Items

Update

$ curl -X PUT localhost:8000/item/1 \
-H "Content-Type: application/json" \
-d '{"id": 1, "name": "Milk", "price": 1500, "description": "Nice milk rebate", "on_offer": true}'

Delete

$ curl -X DELETE localhost:8000/item/5 \
-H "Content-Type: application/json" \
-d '{"id": 4, "name": "Coffee", "price": 5000, "description": "Nice coffee", "on_offer": false}'

Connect WSL2 to Window's Postgres database

Follow these intructions: https://stackoverflow.com/a/67596486

Use this repo as a template to deploy a Python FastAPI service on Render.

See https://render.com/docs/deploy-fastapi or follow the steps below:

Manual Steps

  1. You may use this repository directly or create your own repository from this template if you'd like to customize the code.

  2. Create a new Web Service on Render.

  3. Specify the URL to your new repository or this repository.

  4. Render will automatically detect that you are deploying a Python service and use pip to download the dependencies.

  5. Specify the following as the Start Command.

    uvicorn main:app --host 0.0.0.0 --port $PORT
  6. Click Create Web Service.

Or simply click:

Deploy to Render

Thanks

Thanks to Harish for the inspiration to create a FastAPI quickstart for Render and for some sample code!

fastfly's People

Contributors

fmussari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.