Skip to content

Webアプリ向けのAPIサービスを立ち上げたい

Notifications You must be signed in to change notification settings

sgtao/sgtao-webapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sgtao-webapi

  • Webアプリ向けのAPIサービスを立ち上げたい

setup

git clone

# git clone <repository>
cd sgtao-webapi
python -m venv venv

install packages

source venv/bin/activate
pip install -r ./requirements.txt

run app

uvicorn main:app --reload

for deploy to Deta Space

install space-cli

sudo apt install unzip -y # to install space cli
curl -fsSL https://get.deta.dev/space-cli.sh | sh
exec -l $SHELL

login Deta space

  • 前もってDeta spaceにログインして、Tokenを発行しておく
space login
# Enter Token after exec. command

実行ログ

$ space login
To authenticate the Space CLI with your Space account, generate a new access token in your Space settings and paste it below:
? Enter access token (xx chars) > *************************
👍 Login Successful!
Checking for new Space CLI version...

create project

space new

edit Spacefile

# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
v: 0
micros:
  - name: webapi
    src: .
    path: api
    engine: python3.9
    public_routes:
      - "/api/allinone/*"

deploy project

space push
  • 実行したら、Deta Spaceでプロジェクトを確認する
    • private Cloud上で、FastAPI docsでAPI挙動を確認
    • ローカルから APIのURIを確認
$ curl -X 'GET' 'https://sgtaowebapi-xxx.deta.app/api/allinone/' \
  -H 'accept: application/json' -s | jq
{
  "message":"hello from allinone."
}

License

  • MIT License.

About

Webアプリ向けのAPIサービスを立ち上げたい

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages