File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ from .v1 import v1
Original file line number Diff line number Diff line change 1+ from flask import Blueprint
2+
3+ # v1 blueprint
4+ v1 = Blueprint ("v1" , __name__ , url_prefix = "/api/v1" )
5+
6+ from .views import *
7+ from .plan import *
Original file line number Diff line number Diff line change 1+ from flask import jsonify
2+ from flask .views import MethodView
3+
4+ from . import v1
5+
6+ # test v1 api endpoint.
7+ class Plan (MethodView ):
8+ def get (self ):
9+ return jsonify ({"test" : "This is plan api" }), 200
10+
11+ v1 .add_url_rule ("/plan" , view_func = Plan .as_view ("plan" ))
Original file line number Diff line number Diff line change 1+ from flask import jsonify
2+ from flask .views import MethodView
3+
4+ from . import v1
5+
6+ # test v1 api endpoint.
7+ class Live (MethodView ):
8+ def get (self ):
9+ return jsonify ({"Live" : True , "version" : "v0.0.1" }), 200
10+
11+ v1 .add_url_rule ("" , view_func = Live .as_view ("live" ))
Original file line number Diff line number Diff line change 11from flask import Flask
22from sqlalchemy import create_engine
33
4- from connection import conn
5- from model .subscription import hello
4+ from api .v1 import v1
5+
6+ # from connection import conn
7+ # from model.subscription import hello
68
79def create_app ():
810 app = Flask (__name__ )
911
10- # open a cursor to perform database operations
11- cur = conn .cursor ()
12- # print("Cursor opened successfully", cur)
13- # engine = create_engine('postgresql:///tutorial.db', echo=True)
14- hello ()
15- # Execute a database query
16- cur .execute ("SELECT * FROM student;" )
17-
18- # Fetch the result
19- result = cur .fetchall ()
2012 print ("Result fetched successfully" )
2113
14+ app .register_blueprint (v1 )
15+
2216 @app .route ("/" )
2317 def index ():
24- return result
18+ return "hello how are you!"
2519
2620 return app
2721
Original file line number Diff line number Diff line change 1+ from sqlalchemy import create_engine
2+
3+ engine = create_engine ("sqlite+pysqlite:///:memory:" , echo = True )
You can’t perform that action at this time.
0 commit comments