Create easy REST api with python
191
/restpy/Dockerfile
, info
CMD ./run.sh
Start your webserver, don't copy another
run.sh
!):FROM shark2byte/rest4python:latest
COPY . .
CMD ./run.sh
Readme.md
file to get help for pythonfile, you can find an example in this repo under
/restpy/pytest.py[]
that includes objects like this
{"lang": "py", "file": "myfile.py", "path": "/my/api/path"}
at lang you can input
html
or
pydocker build -t my/server .docker run -p 80:8080 -d my/serverYou Python file will be executed by the server if a user hit the page what you defined in setup.json.
print one json formatted file
print('{"myapi": "some content for my server"}')
, you can also concat it like this:print("{")
print('"myapi":"')
print("some content for my server")
print('"')
print("}")
?
in the url, you can access it with python)
Add at the top of your python file this code:import sys
import json
query=json.loads(sys.argv[1])
to access the query via
query
, example: user call your python file with the url ending
?hello=world
, then you can access the
world
part via
query["hello"]
You find a Example in this Repos in the folder restpy
If the dockerfile work not, use git clone https://github.com/Sharkbyteprojects/REST-Python.git to clone the repos, change the files in the folder restpy and start with NODE JS npm start in the main folder of the repos
Content type
Image
Digest
Size
34.4 MB
Last updated
over 6 years ago
docker pull shark2byte/rest4python