Giter Site home page Giter Site logo

flask-echo-server's Introduction

Flask Echo Server

License: MIT Code style: black

A simple Flask application that can be used to test HTTP calls. It simply logs out the request and request data then returns an object with the request information. Useful for debugging HTTP calls to third-party APIs by making the same calls to this server or developing applications locally when you don't want to call real API endpoints.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development.

Prerequisites

Install Dependencies

First, install dependencies:

$ pipenv install
Creating a virtualenv for this project…
...
Virtualenv location: /Users/user/.virtualenvs/flask-echo-server-zyMB51yv
Installing dependencies from Pipfile.lock (8a3288)…
  🐍   β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 6/6 β€” 00:00:04
To activate this project's virtualenv, run the following:
 $ pipenv shell

Activate the virtual environment:

$ pipenv shell
Spawning environment shell (/bin/zsh). Use 'exit' to leave.
(flask-echo-server-zyMB51yv) $

Start the Application

Run the application:

$ export FLASK_ENV=development; flask run
 * Environment: development
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: XXX-XXX-XXX

Usage

Example: POST JSON

$ curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST 127.0.0.1:5000/api/v1/test
{
  "data": "{\"key1\":\"value1\", \"key2\":\"value2\"}",
  "endpoint": "api/v1/test",
  "form": {},
  "json": {
    "key1": "value1",
    "key2": "value2"
  }
}

Server log:

*** Received data at: api/v1/test
data b'{"key1":"value1", "key2":"value2"}'
form ImmutableMultiDict([])
json {'key1': 'value1', 'key2': 'value2'}

Example: POST Form Data

$ curl -d "param1=value1&param2=value2" -X POST 127.0.0.1:5000/api/v1/test
{
  "data": "",
  "endpoint": "api/v1/test",
  "form": {
    "param1": "value1",
    "param2": "value2"
  },
  "json": null
}

Server log:

*** Received data at: api/v1/test
data b''
form ImmutableMultiDict([('param1', 'value1'), ('param2', 'value2')])
json None

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

Wanna Cuttle?

flask-echo-server's People

Contributors

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