Code Monkey home page Code Monkey logo

fastapi_web's Introduction

pip install fastapi[all]을 설치했다.

.gitignore 파일 생성후

/Lib
/Include
/Scripts
pyvenv.cfg

fastapi를 이용한 웹서버

가상환경을 구성 하기 위해서

python -m venv fastapi_web
cd fastapi_web

Scripts\activate

>>> (fastapi_web) C:\apps\fastapi_web>

.gitignore 파일 생성후

/Lib
/Include
/Scripts
pyvenv.cfg

파이썬을 이용해서 웹서버를 구현하기 위해 flask 라이브러리 및 framework 를 사용한다.

pip를 이용해서 설치 한다.

pip install fastapi[all] uvicorn

라이브러리 설치 목록을 따로 만들어 관리하면 다른 곳에서 프로젝트를 구현할때 편리하다.

pip freeze > requirements.txt

requirements.txt 에 있는 내용대로 라이브러리를 설치하는 방법은 다음과 같다.

pip install -r requirements.txt

image

위와 같은 구조로 웹서버를 만든다.

image

다음과 같은 기능을 구현하기 위해

url : http://localhost:8000

method : GET 방식

data : Hello World!! 텍스트 데이터가 클라이언트에 전송되도록 한다.

main.py를 생성후 다음과 같이 코드를 추가한다.

from fastapi import FastAPI

app = FastAPI()

@app.get('/')
async def main():
    return {"message":"Hello World"}

fastapi_web's People

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.