!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.4.18 (Ubuntu). PHP/7.0.33-0ubuntu0.16.04.16 

uname -a: Linux digifus 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/tmp/junk/   drwxrwxr-x
Free 10.24 GB of 29.4 GB (34.82%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     app.py (3.81 KB)      -rwxrwxr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
from flask import Flask
from flask.ext.api import status


from json import dumps
from json import loads
from flask import request
from flask import Response
import database_functions

app = Flask(__name__)

#Create an instance of SQLAclhemy
#from flask.ext.sqlalchemy import SQLAlchemy
#db = SQLAlchemy(app)

flask_debug = True

    
# API REST
@app.route('/product', methods=['GET'])
def get_product_list():
    # return foreach product {id, name, description, price, qr}
    return dumps(database_functions.get_all_products())


@app.route('/product', methods=['POST'])
def add_product():
    # data: ex. { 'id' : null, 'name': 'product', 'description': 'a product named product', 'price': 0.5}
    #name = request.form['name']
    #description = request.form['description']
    #price = float(request.form['price'])
        json_request = loads(request.data)
        name = json_request['name']
        description = json_request['description']
        price = json_request['price']
    qr_code = database_functions.create_qr_for_new_product(name)

    database_functions.insert_product(name, description, price)

    return Response("Producto creado", status=200, mimetype='application/json')

@app.route('/product/<string:product_id>', methods=['PUT'])
def update_product(product_id):
    pass 

@app.route('/product/<string:product_id>', methods=['GET'])
def get_product_detail(product_id):
    return dumps(database_functions.get_product_by_name(product_id))

@app.route('/product/<string:product_id>/qr', methods=['GET'])
def get_qrcode(product_id):
    from flask import send_file
        filename = database_functions.get_qr_filename_from_product(product_id)
        # TODO: Verify filename is not None
    return send_file(filename, mimetype='image/png')

@app.route('/order', methods=['POST'])
def create_order():
        ''' {
            "id": null,
            "seller_id": "seller 1",
            "client": "client_id",
            "products": [
                {
                    "name": "product1",
                    "count": 5
                },
                ...
             ]
            }
        '''
        json_request = loads(request.data)

        seller_id = json_request['seller_id']
        client_id = json_request['client_id']
        products = json_request['products'] 
    database_functions.insert_order(seller_id, client_id, products)
    return Response("Orden creada", status=200, mimetype='application/json')

@app.route('/client', methods=['GET'])
def get_all_clients():
    # return foreach client {id, name, business_name , address, cuit, city, iva, mail }
    clients = database_functions.get_all_clients()
    # Avoid to convert unicode string. Clients has characters no ascii
    json = dumps(clients, ensure_ascii=False)
    return json

@app.route('/client', methods=['POST'])
def add_new_client():
        # data: ex. { 'name': 'client', 'bussiness_name': 'client SRL', 'address': 'client addres 1234',
        #             'city' : 'client city', 'phone': '0800000', 'cuit': '20-client-3', 'mail': 'client@client.com', 'iva': 'responsable inscripto',
        #             'observation': '', 'expresso': ''}
    print request.data
        json_request = loads(request.data)
    name = json_request['name']
    business_name = json_request['business_name']
    address = json_request['address']
    city = json_request['city']
    phone  = json_request['phone']
    cuit = json_request['cuit']
        mail = json_request['mail']
    expresso = json_request['expresso']  
    database_functions.insert_client(name, business_name, address, city, phone, cuit, mail, expresso)

    return Response("Cliente creado", status=200, mimetype='application/json')

@app.route('/client/<string:client_bussines_name>', methods=['GET'])
def get_client(client_bussines_name):
    return dumps(database_functions.get_client_by_business_name(client_bussines_name))

if __name__ == '__main__':
    app.run('0.0.0.0', debug=flask_debug)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.006 ]--