54 lines
1.2 KiB
Python
Raw Normal View History

2020-01-08 15:57:00 -05:00
import connexion
from flask import url_for, json
PROTOCOLS = {}
2020-02-11 14:50:32 -05:00
def get_user_studies(user_id):
2020-01-08 15:57:00 -05:00
return {"protocols": [p for p in PROTOCOLS.values() if p['user_id'] == user_id][:limit]}
2020-02-11 14:50:32 -05:00
def required_docs(id):
2020-01-08 15:57:00 -05:00
return {
id: 21,
requirements: []
}
2020-02-11 14:50:32 -05:00
def investigators(id):
2020-01-08 15:57:00 -05:00
return
2020-02-11 14:50:32 -05:00
def get_protocol(id):
2020-01-08 15:57:00 -05:00
return
2020-02-11 14:50:32 -05:00
def get_form(id, requirement_code):
return
2020-01-08 15:57:00 -05:00
app = connexion.App('Protocol Builder', specification_dir='./')
app.add_api('api.yml')
application = app.app
def has_no_empty_params(rule):
defaults = rule.defaults if rule.defaults is not None else ()
arguments = rule.arguments if rule.arguments is not None else ()
return len(defaults) >= len(arguments)
@application.route("/")
def site_map():
links = []
for rule in application.url_map.iter_rules():
# Filter out rules we can't navigate to in a browser
# and rules that require parameters
if "GET" in rule.methods and has_no_empty_params(rule):
url = url_for(rule.endpoint, **(rule.defaults or {}))
links.append((url, rule.endpoint))
return json.dumps({"links": links})
2020-01-08 16:05:16 -05:00
if __name__ == '__main__':
# run our standalone gevent server
app.run(port=4200)