flaspi (easy api maker for flask)
下の方に日本語の説明があります
Overview
- A tool to create flask APIs easily.
- API for sending and receiving JSON
- Note that it is not a strict RESTful API.
Usage example
- Server side
import flask
import flaspi
# Define a flask app (web server)
app = flask.Flask(__name__)
# function describing the API behavior
def greeting_func(req_obj):
return {"message": "Hello, %s!!"%req_obj["name"]}
# Define the API for post (params: the URL path, the function that defines the API action, and the flask app)
flaspi.post_api("/greeting", greeting_func, app = app)
# run flask server
app.run(host = "0.0.0.0", port = "80", debug = False)
- Example API call
curl http://localhost:80/greeting -X POST -H "Content-Type: application/json" --data '{"name": "Hoge"}'
- Result (response)
{"message": "Hello, Hoge!"}
- Example of API call (using flaspi)
res = flaspi.call_post_api("http://localhost:80/greeting", {"name": "Hoge"}) # -> (200, {'message': 'Hello, Hoge!!'})
概要
- flaskのAPIを簡単に作れるツール
- JSONを送受信する形のAPI
- 厳密なRESTful-APIではないので注意
使用例
- サーバー側
import flask
import flaspi
# flaskのアプリ(ウェブサーバー)を定義
app = flask.Flask(__name__)
# APIの動作を記述した関数
def greeting_func(req_obj):
return {"message": "Hello, %s!!"%req_obj["name"]}
# postのAPIを定義 (URLのパス、動作を定義した関数、flaskのappを渡す)
flaspi.post_api("/greeting", greeting_func, app = app)
# flaskサーバー立ち上げ
app.run(host = "0.0.0.0", port = "80", debug = False)
- APIの呼び出し例
curl http://localhost:80/greeting -X POST -H "Content-Type: application/json" --data '{"name": "Hoge"}'
- 結果 (レスポンス)
{"message": "Hello, Hoge!!"}
- APIの呼び出し例 (flaspiを利用した場合)
res = flaspi.call_post_api("http://localhost:80/greeting", {"name": "Hoge"}) # -> (200, {'message': 'Hello, Hoge!!'})
Metadata
Release files for flaspi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flaspi-0.1.0.tar.gz | 3.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flaspi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / flaspi-0.1.0.tar.gz
| Download URL | flaspi-0.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78593007317c77044bfdf9ddb09e4850ae2fc1645c0a37031f984c2a807be40e
|
|
BLAKE2b-256 checksum How to use checksums |
c0d3cbb6b59b2690313376ae485d1310e88ad8edb4374d6e5bc1f436b68da09f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / flaspi-0.1.0-py3-none-any.whl
| Download URL | flaspi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2074081663e5408337d0052de80ae2fdcef9e82887fdd6b007128b258f5be3b9
|
|
BLAKE2b-256 checksum How to use checksums |
c1031ecd0f6ff625e0c5829770dee2ba14344cdc7209d11b4a3b8266ab00c59f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for flaspi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.