mirror of
https://github.com/Manuel83/craftbeerpi3
synced 2026-09-19 07:49:08 +02:00
1
Custom Web Endpoint
Manuel83 edited this page 2017-07-03 07:07:17 +02:00
Adding a new HTTP Endpoint is also possible.
In the following example the endpoint will be available under:
http://<RASPI_IP>:5000/api/myendpoint/
The endpoint name must be unique in the entire system.
See Flask BluePrint for more information
# -*- coding: utf-8 -*-
import os
from subprocess import Popen, PIPE, call
from modules import cbpi
import json
from flask import Blueprint, render_template, jsonify, request
blueprint = Blueprint('http_sensor1', __name__)
@blueprint.route('/', methods=['GET'])
def hello_world():
return "HELLO WORLD"
@cbpi.initalizer()
def init(cbpi):
cbpi.app.register_blueprint(blueprint, url_prefix='/api/myendpoint')
print "READY"