Giter Site home page Giter Site logo

pingit's Introduction

PingIt

Samll Flask API application, build just for fun.

Installation is simple. Just run this command with docker:

$ docker build --tag pingit .

Run application:

$ docker run -p 5000:5000 pingit

Resolve 127.0.0.1:5000 in Your browser to get into API documentation

Swagger screenshot

set Flask_APP

export FLASK_APP=app.py

Avaliable flask commands:

run               Runs a development server.
shell             Runs a shell in the app context.
start-dev-server  Start development server.
start-server      Start server.
stop-server       Stop server.

Some examples:

Start Development Server

flask start-dev-server

Start Server (using gunicorn)

flask start-server

Stop Server (kill gunicorn processes)

flask stop-server

Checking etag:

curl -i http://localhost:5000/info
HTTP/1.1 200 OK
Server: Werkzeug/2.1.0 Python/3.7.0
Date: Thu, 31 Mar 2022 19:38:25 GMT
Content-Type: application/json
Content-Length: 34
ETag: "401f6fd4e83461d236a7399206c2e2d42e05f27b"
Date: Thu, 31 Mar 2022 19:38:25 GMT

{"Receiver": "Cisco is the best!"}

Checking if etag works:

curl -i http://localhost:5000/info -H 'If-None-Match: 401f6fd4e83461d236a7399206c2e2d42e05f27b'                                                                                                                                                                       130 ↵
HTTP/1.1 304 NOT MODIFIED
Server: Werkzeug/2.1.0 Python/3.7.0
Date: Thu, 31 Mar 2022 19:39:46 GMT
ETag: "401f6fd4e83461d236a7399206c2e2d42e05f27b"
Date: Thu, 31 Mar 2022 19:39:46 GMT
Transfer-Encoding: chunked

Hit ping endpint example:

curl -i -X POST -H "content-type: application/json" -d '{"url": "http://foobar.com"}' http://localhost:5000/ping
HTTP/1.1 200 OK
Server: Werkzeug/2.1.0 Python/3.7.0
Date: Thu, 31 Mar 2022 19:40:50 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked

<html><head><title>Error 403 - Forbidden</title><head><body><h1>Error 403 - Forbidden</h1><p>You don't have permission to access the requested resource. Please contact the web site owner for further assistance.</p></body></html>

Stream response with pingit endpoint example:

PingIt example GIF

pingit's People

Contributors

riv2q 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.