Skip to content

base on falcon framework,some useful tools post image, numpy and json file or parameters

License

Notifications You must be signed in to change notification settings

aidings/fcserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fcserver

base on falcon framework, some useful tools post image, numpy and json file or parameters

install

pip install git+https://github.com/aidings/fcserver.git

example

  1. server(deploy model)

     from fcserver import FalconServer, App
     from PIL import Image
     from wsgiref.simple_server import make_server
    
    
     class Server(FalconServer):
         def __init__(self, *args, **kwargs):
             super().__init__(*args, **kwargs)
    
             print('My server model loadding...')
         
         def on_post(self, req, resp):
             # pudb.set_trace()
             # print(req.params)
             # img_a = self.decode_image(req, 'aimg')
             img_a = self.decode_numpy(req, 'aimg')
             self.save_data('aimg.png', img_a)
             img_b = self.decode_image(req, 'bimg')
             self.save_data('bimg.png', img_b)
    
             resp.body = json.dumps('aimg': 'is a numpy', 'bimg': 'is a image')
    
     s = Server()
    
     app = App()
     app.add_route('/ding', s)
    
     if __name__ == '__main__':
         with make_server('127.0.0.1', 8088, app) as httpd:
             httpd.serve_forever()
  2. client(send data to server)

     import cv2
     import json
     from fcserver import FalconClient
    
     if __name__ == '__main__':
         c = FalconClient('https://127.0.0.1:8088/ding', None)
    
         c.push_file(cv2.imread('./demo.png'), 'aimg', is_img=False)
         c.push_file('./demo2.png', 'bimg')
         # print(files)
    
         c.send(query={'test': [1, 2, 3]}, data={'a': [4, 5, 6]})
  3. gunicorn(deploy the server) gunicorn --workers=2 --bind 0.0.0.0:8088 demo:app

  4. uwsgi(deploy the server) uwsgi --ini uwsgi.ini

About

base on falcon framework,some useful tools post image, numpy and json file or parameters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages