Code Monkey home page Code Monkey logo

http_1_2_3_restfulapi_pyscript_hypercorn_fastapi's Introduction

Fullstack Service Networking Season.2
HyperCorn & FastApi RESTful API Program

Server : Python (HyperCorn ASGI Server + FastApi Application)

Client : Web Browser (PyScript : Python in HTML, Pico.css)

Networking : HTTP/1.1, HTTP/2, HTTP/3

Packaging : Poetry (추가 패키지: hypercorn, aioquic, h3, fastapi)



Overall Architecture

WSGI/ASGI Architecture.

(출처: https://derlin.github.io/introduction-to-fastapi-and-celery/02-fastapi/)



실행 방법

NOTE

macOS & Linux : 제한 사항 없음
MS Windows :

Server : WSL2 사용을 권장함
Client :

HTTP/1.1 & HTTP/2 : Windows에서 Chrome 브라우저(chrome.exe)를 실행후, WSL2의 서버로 접속함
HTTP/3 : WSL2에서 Chrome 브라우저 실행후, WSL2의 서버로 접속함

Chrome 브라우저를 WSL2에 설치하고 실행하는 방법은 다음을 참조함
https://learn.microsoft.com/ko-kr/windows/wsl/tutorials/gui-apps

프로젝트를 다운로드 함

폴더안에서 poetry shell를 실행함

poetry shell

폴더안에서 필요한 패키지를 설치함

poetry install

src/server.py를 실행함

HTTP/1.1

poetry run hypercorn server_app:app

HTTP/2

poetry run hypercorn --certfile cert/localhost.crt --keyfile cert/localhost.key --bind localhost:8000 server_app:app

HTTP/2 & HTTP/3

poetry run hypercorn --quic-bind localhost:4433 --certfile cert/localhost.crt --keyfile cert/localhost.key --bind localhost:8000 server_app:app

Chrome browser로 서버에 접속함

HTTP/1.1

http://127.0.0.1:8000/

HTTP/2

https://127.0.0.1:8000/

HTTP/3

Chrome browser를 HTTP/3 모드로 강제 실햄함

macOS 경우:

sudo /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-quic --allow-insecure-localhost --origin-to-force-quic-on=127.0.0.1:4433 --ignore-certificate-errors-spki-list="Vy/mwFlqWXlxva7JH2xXR0bShco74LOb7xG1dFlZlrA="

https://127.0.0.1:4433/

Linux 경우:

google-chrome --enable-quic --allow-insecure-localhost --origin-to-force-quic-on=127.0.0.1:4433 --ignore-certificate-errors-spki-list="Vy/mwFlqWXlxva7JH2xXR0bShco74LOb7xG1dFlZlrA="

https://127.0.0.1:4433/

화면 위쪽의 “Please wait, program is starting …” 문구가 다음처럼 바뀌기를 기다림
Please fills key/value and executes menu :

CREATE 동작을 위하여,
CREATE 버튼 왼쪽의 Key와 Value에 각각 apple과 1000을 입력하고, CREATE 버튼을 클릭함
CREATE 결과를 웹브라우저 화면과 서버 출력 화면에서 확인함

READ 동작을 위하여,
READ 버튼 왼쪽의 Key에 apple을 입력하고, READ 버튼을 클릭함
READ 결과를 웹브라우저 화면과 서버 출력 화면에서 확인함

UPDATE 동작을 위하여,
UPDATE 버튼 왼쪽의 Key와 Value에 각각 apple과 2000을 입력하고, UPDATE 버튼을 클릭함
UPDATE 결과를 웹브라우저 화면과 서버 출력 화면에서 확인함

DELETE 동작을 위하여,
DELETE 버튼 왼쪽의 Key에 apple을 입력하고, DELETE 버튼을 클릭함
DELETE 결과를 웹브라우저 화면과 서버 출력 화면에서 확인함

서버 종료를 위하여 ctrl-c 키보드 입력을 수행함

Client를 실행하기 위해서, 실행한 Python http.server를 ctrl-c 키보드 입력으로 종료함

Poetry 실행을 중지함

exit



실행 화면

http_1_2_3_restfulapi_pyscript_hypercorn_fastapi's People

Contributors

drsungwon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.