Skip to content

Python package to generate a flask server from any class definition

Notifications You must be signed in to change notification settings

arvind-iyer/easyweb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Web

Simple tool for prototyping web applications.

Installation

To install Easy Web run

pip install easyweb

Usage

You can call Easy Web on any Python class whose methods expect primitive arguments like strings, numbers.

Here's an example of calling Easy Web on a class.

import easyweb

class Calculator(object):
  """A simple calculator class."""

  def add(self, a, b):
    return a + b

c = Calculator()

if __name__ == '__main__':
  easyweb.run(c)

Then, you can make requests like this: http://localhost:5000/calculator/add?a=5&b=6

And get a json response: {'result': 11}

And a Flask file would be generated like so:

import calculator
calculator_instance = calculator.Calculator()

from flask import Flask, jsonify
app = Flask(__name__)

@app.route("/calculator/add")
def add():
    a = request.args.get('a')
    b = request.args.get('b')
	result = calculator_instance.add(a, b)
	return jsonify(result)

About

Python package to generate a flask server from any class definition

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages