For programmers to need to call api by Python using REST API,this tested source code is useful. This sample code includes client/server code and you can use it as template of REST API.
Specification
ID | STCD_0000000015 |
Language | Python |
Steps | 146 |
Purpose | Pay by PayPal |
Function | get token (JWT) send POST with token send GET with token send PUT with token send DELETE with token |
Environment | Ubuntu 20.04.4 LTS Anaconda3(Python 3.9.7) IDE : Visual Studio Code |
Restriction | free license You can use source code copy as owner . You can customize and distribute it freely. |
Price | 7 dollars or 700 yen (Pay with PayPal) |
References | https://www.ymstmsys.jp/blog/2022/02/05/ https://qiita.com/kerobot/items/8ef8d7416742eedcea49 https://www.w2solution.co.jp/corporate/tech/flaskapi%E3%81%A7jwt%E8%AA%8D%E8%A8%BC%E3%82%92%E5%AE%9F%E8%A3%85%E3%81%99%E3%82%8B%EF%BC%88%E5%BE%8C%E7%B7%A8%EF%BC%89/ https://qiita.com/kerobot/items/c5607658171c2aec4f46 https://qiita.com/LJsteve/items/43afabce54c07fcd31c3 https://flask-jwt-extended.readthedocs.io/en/stable/options/#jwt-algorithm |
Source Code
- Client( = Test Code)
- Server
Test Result
NO | test case | result |
01 | get token (JWT) | OK |
02 | send POST | OK |
03 | send GET | OK |
04 | send PUT | OK |
05 | send DELETE | OK |
History
16/4/2023 created
Provider Profile
Nick name is “Dead Fish” employed as an engineer in Japan.
I am grad if you need my code.
Thanks !
Download
Get download passwordSTCD_0000000015
1 file(s) 0.18 KB
Following files and data are zipped.
├── key_store │ ├── server.crt │ └── server.key ├── test_restapi_client.py └── test_restapi_server.py
Remarks
To run server using flask embedded web server, refer to following :
$ export FLASK_APP=test_restapi_server
$ flask run --cert key_store/server.crt --key key_store/server.key --port=50443
* Serving Flask app 'test_restapi_server'
* Debug mode: off
Enter PEM pass phrase: <test>
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on https://127.0.0.1:50443
Press CTRL+C to quit
None
Comments