Giter Club home page Giter Club logo

fast-api-deploy-to-deta's Introduction

Deploy a FastAPI app to Deta Space

Sometimes you need to host an API anywhere in the web because you had this crazy idea on doing one more todo app during your insomnia but then you realize Heroku is no longer free for this.

No worries, there are several free options in the web. This project aims to show you how to deploy a FastAPI app to Deta Space.

Setting up Deta Space

You should have the Space CLI installed.

You should get the access the token from your Deta Space settings:

space login

Then we create our new project (I'm calling it fast-api-sample here):

space new

The Spacefile

Your Spacefile should look similar to this:

v: 0
app_name: "FAPI SAMPLE"
micros:
  - name: fastapi-sample
    src: ./
    engine: python3.9
    dev: .venv/bin/uvicorn main:app --reload

Remember, main:app refers to main.py file / module and app

The FastAPI app

This is the simplest FastAPI app you can get:

from fastapi import FastAPI

app = FastAPI()


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

Remember, you need the requirements.txt file with all the needed dependencies. In this case, the simpler is:

fastapi

Deploying the app

Now, you just need to push the app:

space push

And if everything is right, you should receive a happy message like this in the end:

๐ŸŽ‰  Successfully pushed your code and updated your Builder instance!
Builder instance: <https://fastapisample-1-p5210071.deta.app>

And your API is up in the web โ›….

๐Ÿ—๏ธHappy building!

fast-api-deploy-to-deta's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

sunghoonism

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.