Bachelorthesis_Code/backend/src/app.py

48 lines
894 B
Python
Raw Normal View History

import time
from flask import Flask
2021-06-22 00:15:40 +00:00
import flask_sqlalchemy
import flask_praetorian
import flask_cors
2021-06-21 22:58:08 +00:00
import os
app = Flask(__name__)
2021-06-21 22:58:08 +00:00
# Read environment variables
if "DEBUG" in os.environ and os.environ["DEBUG"] == 'yes':
debug = True
else:
debug = False
if "HOST" in os.environ:
host = os.environ["HOST"]
else:
host = '0.0.0.0'
if "PORT" in os.environ:
port = int(os.environ["PORT"])
else:
port = 5000
2021-06-22 00:15:40 +00:00
db = flask_sqlalchemy.SQLAlchemy()
guard = flask_praetorian.Praetorian()
cors = flask_cors.CORS()
class User(db.Model):
2021-06-22 00:15:40 +00:00
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.Text, unique=True)
password = db.Column(db.Text)
2021-06-21 22:58:08 +00:00
@app.route('/')
def home():
return "Hello World"
@app.route('/time')
def get_current_time():
return {'time': time.time()}
2021-06-21 22:58:08 +00:00
if __name__ == '__main__':
app.run(debug=debug, host=host, port=port)