endpoints.py added, db.py added and able to store data in db
This commit is contained in:
parent
99ae76c303
commit
b7f62bbe97
3 changed files with 35 additions and 0 deletions
10
api/db.py
Normal file
10
api/db.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import redis
|
||||
|
||||
# connection string and initialization
|
||||
redis_url = 'redis://default:redispw@localhost:32768'
|
||||
r = redis.StrictRedis.from_url(redis_url)
|
||||
|
||||
#test the connection
|
||||
r.set('hello', 'world')
|
||||
value = r.get('hello')
|
||||
print(value)
|
11
api/endpoints.py
Normal file
11
api/endpoints.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from typing import *
|
||||
import flask
|
||||
|
||||
class Endpoints:
|
||||
|
||||
def __init__(self, app: flask.Flask):
|
||||
app.add_url_rule("/hello", view_func=self.hello, methods=["GET"])
|
||||
|
||||
|
||||
def hello(self):
|
||||
return "Hello world!"
|
14
api/main.py
Normal file
14
api/main.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import flask
|
||||
from flask import *
|
||||
import endpoints
|
||||
|
||||
def main():
|
||||
app = flask.Flask(__name__)
|
||||
endpoints.Endpoints(app)
|
||||
app.run(port=8080, debug=True, host="127.0.0.1")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Reference in a new issue