mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Start to create views
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
|
||||||
|
def create_app():
|
||||||
|
application = Flask(__name__)
|
||||||
|
|
||||||
|
# application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
||||||
|
# application.config.from_object(configs[config_name])
|
||||||
|
from .main import main as main_blueprint
|
||||||
|
application.register_blueprint(main_blueprint)
|
||||||
|
|
||||||
|
return application
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from flask import Blueprint
|
||||||
|
|
||||||
|
main = Blueprint('main', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
from .views import index
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from .. import main
|
||||||
|
|
||||||
|
|
||||||
|
@main.route('/index')
|
||||||
|
def index():
|
||||||
|
return 'Hello from notifications-admin'
|
||||||
|
|
||||||
+22
-6
@@ -1,11 +1,27 @@
|
|||||||
from flask import Flask
|
#!/usr/bin/env python
|
||||||
|
|
||||||
app = Flask(__name__)
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from flask.ext.script import Manager, Server
|
||||||
|
|
||||||
|
from app import create_app
|
||||||
|
|
||||||
|
application = create_app()
|
||||||
|
manager = Manager(application)
|
||||||
|
port = int(os.environ.get('PORT', 6012))
|
||||||
|
manager.add_command("runserver", Server(host='0.0.0.0', port=port))
|
||||||
|
|
||||||
|
# migrate = Migrate(application, db)
|
||||||
|
# manager.add_command('db', MigrateCommand)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@manager.command
|
||||||
def index():
|
def list_routes():
|
||||||
return 'Hello from notifications-admin'
|
"""List URLs of all application routes."""
|
||||||
|
for rule in sorted(application.url_map.iter_rules(), key=lambda r: r.rule):
|
||||||
|
print("{:10} {}".format(", ".join(rule.methods - set(['OPTIONS', 'HEAD'])), rule.rule))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(port=6012)
|
manager.run()
|
||||||
|
|||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
python application.py runserver
|
||||||
Reference in New Issue
Block a user