REST API sample code

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

IDSTCD_0000000015
LanguagePython
Steps146
PurposePay by PayPal
Functionget token (JWT)
send POST with token
send GET with token
send PUT with token
send DELETE with token
EnvironmentUbuntu 20.04.4 LTS
Anaconda3(Python 3.9.7)
IDE : Visual Studio Code
Restrictionfree license
You can use source code copy as owner .
You can customize and distribute it freely.
Price7 dollars or 700 yen
(Pay with PayPal)
Referenceshttps://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

NOtest caseresult
01get token (JWT)OK
02send POSTOK
03send GETOK
04send PUTOK
05send DELETEOK

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 password

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

Copied title and URL