This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Simple and opiniated way to build APIs in Python.

FuncServer An abstraction to implement web accessible servers hosting any sort of functionality. This is built on a Tornado core and supports interacting with the server using a web based python terminal making debugging and maintenance easy. In addition the logs emitted by the process can be viewed from within the web interface.

Installation

pip install funcserver

Usage

Basic example

The following is the code to implement the most basic Functionality Server.

from funcserver import Server

if __name__ == '__main__':
    Server()

Run it by doing

python example.py run

This server is now started and listening on default port 9345 for commands. You can interact with it using the Web UI by visiting http://localhost:9345/

If you want to start it on a different port, do

python example.py run --port <port no>

Things to do in the Console

# see the objects available in the console env
>>> dir()

# write a message to log (open the log tab in a new browser window
# to see the logged message being echoed back). you can use the log
# tab to observe all the logs being written by the application.
>>> server.log.warning('something is happening')

# set a different log level
>>> server.log.setLevel(logging.DEBUG)

# you can import any python module here
>>> import datetime

Calculation server (another example)

You will find an example script in examples/ called calc__server.py.

python examples/calc_server.py

To use the server’s functionality, run the provided example client script in examples/ directory.

python examples/calc_client.py

Debugging using PDB

When it is required to debug the API code using the Python debugger you may have to trigger the API function from the web based python console. However due to the design of FuncServer PDB does not work well in the scenario (as a result of the output being captured by the python interpretation part of FuncServer). To work around this issue a facility has been provided in the form of the “call” utility function available in the python console namespace. The usage is show below.

Let us assume that you have pdb trace set in code as follows:

def some_api_fn(self, a, b):
    import pdb; pdb.set_trace()
    c = a + b
    return c

If you call this api function as follows then debugging will not work and the api call will block from the console.

>>> api.some_api_fn(10, 20)

Instead do this:

>>> call(lambda: api.some_api_fn(10, 20))

Now the pdb console will appear in the terminal where you started your server.

Multiprocessing and disabling gevent

Gevent offers a great amount of convenience however it is currently
incompatible with python’s multiprocessing module. Here is an example on how
to disable gevent so you can use multiprocessing.

disable_gevent.py

from gevent import monkey; monkey.patch_all = lambda: None

from funcserver import Server

class MyServer(Server):
    def run(self):
        # do something here including using
        # `multiprocessing` module
        pass

if __name__ == '__main__':
    MyServer().start()
Release History

Release History

0.2.10

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
funcserver-0.2.10-py2-none-any.whl (247.4 kB) Copy SHA256 Checksum SHA256 py2 Wheel Nov 15, 2016
funcserver-0.2.10.tar.gz (244.5 kB) Copy SHA256 Checksum SHA256 Source Nov 15, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting