Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kennytian/first-python
https://github.com/kennytian/first-python
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/kennytian/first-python
- Owner: Kennytian
- Created: 2024-09-04T09:19:07.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-10-28T08:26:35.000Z (2 months ago)
- Last Synced: 2024-11-08T21:09:29.020Z (about 2 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# First Python
## Run
```shell
uvicorn main:app --reload --host 0.0.0.0 --port 8080
```
```shell
# 如果不加__name__,那么就执行正面的语句,quick-start 是文件名,app 是模块名
uvicorn quick-start:app --reload --host 127.0.0.1 --port 8080
```## Development
```shell
curl http://127.0.0.1:8080
```
```shell
curl -H "access-key: s6FXdoiIxfp3uvlX" http://127.0.0.1:8080/protected
```
```shell
curl -X PUT -H "Content-Type: application/json" -H "Access-Key: s6FXdoiIxfp3uvlX" -d '{"name":"Tom","price":2.23}' http://127.0.0.1:8080/items/121
```
```shell
curl -X GET -H "Access-Key: s6FXdoiIxfp3uvlX" http://127.0.0.1:8080/items/121
```## Build image
```shell
docker rmi -f first-py:latest
docker build -t first-py --no-cache --progress=plain .
```## Run
```shell
# 开发时退出就删除
docker rm -f first-py
docker run --name first-py --rm --env-file .env -p 8000:80 first-py:latest
``````shell
# 生产环境
docker rm -f first-py
docker run --name first-py -d --restart=on-failure:10 --env-file .env -p 8000:80 first-py:latest
```