Giter Club home page Giter Club logo

static-response-server's Introduction

Static Response Server

Serving static files for http requests.

Build Status

So, yeah...after seeing the project Canned, I thinked -"Hey, I already done this two or three times, but never publish, I probably should done this. But different from this guy, I gonna do in Python!".

That's the history behind this project. For now, I've probably used the most heavy weight of the light weight web frameworks for python, Flask, used basicly a gist from one Flask developer and that's it. Not cover all the cases Canner cover, not even 10%. But if you think, is the best scenario to contribute and understand what is happening.

Glad you are reading this and enjoy.

Installation

Linux:

pip3 install static_response_server

Usage example

After start server with

static_response_server -a path/to/your/app

Made requests to http://127.0.0.1 like

Accept: text/html
GET /index.html

And you will be served from the file <path/to/your/app>/index.html.get with content

<!DOCTYPE html>
<html>
    <head>
        <title>Static page</title>
    </head>
    <body>
        <h1>Static Response Server</h1>
        <p>This page is a response GET</p>
    </body>
</html>

Make requests to http://127.0.0.1/person/123/contact from a route with format /person/:id/contact and you will be served from a index file inside directory named any. So, the folder path that this request will access is <path/to/your/app>/person/any/contact/index.html.get (in case the request be GET).

Development

Install dependencies

pip3 install -r requirements.txt

Run tests with nose tests

nosetests

Run server in local app path

python3 server/__init__.py 

Release History

  • 0.0.1
    • Work in progress
    • Add support to routes with wildcards
  • 0.0.2
    • Add to pypi
    • Add console script

Meta

Alex Rocha - about.me

static-response-server's People

Contributors

alexrochas avatar marceloserpa avatar

Stargazers

Octavio Carpes avatar  avatar Philipp Fehre avatar Marcelo Adamatti avatar

Watchers

James Cloos avatar  avatar

Forkers

marceloserpa

static-response-server's Issues

Starting server without '-a' option should assume that the root app is in the current directory.

Today if the server start without options, will assume that the app directory is the one in python code.

~/path/to/app$ server_static_response

The path will be /users/path/to/python/code and this behavior isn't useful.

The change is, once the server start from a path [~path/to/app/]

~/path/to/app/$ server_static_response

the root path will be the actual path, in the example, will be ~/path/to/app.

Create help route

Create help route or change error 404 to contains folder tree and help to identify possible routes.

Something like:

http://127.0.01/help

should output something similar to tree package from debian:

~$ tree ./app
.
├── error
│   └── 404.html
├── index.html.get
└── person
    ├── any
    │   ├── any
    │   │   └── index.html.get
    │   └── index.html.get
    └── index.html.get

Create option '-p' for custom port.

In order to minimize changes in consumer apps, should be able to change which port the app will listen

~$ static_response_server -a 'path/to/app' -p [port]

This way the consumer apps will not have to change port value inside their code just to use our server.

Create option -p for custom port.

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.