mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-10 07:03:12 -05: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
|
||||
|
||||
|
||||
6
app/main/__init__.py
Normal file
6
app/main/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from flask import Blueprint
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
|
||||
from .views import index
|
||||
0
app/main/views/__init__.py
Normal file
0
app/main/views/__init__.py
Normal file
7
app/main/views/index.py
Normal file
7
app/main/views/index.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from .. import main
|
||||
|
||||
|
||||
@main.route('/index')
|
||||
def index():
|
||||
return 'Hello from notifications-admin'
|
||||
|
||||
@@ -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('/')
|
||||
def index():
|
||||
return 'Hello from notifications-admin'
|
||||
@manager.command
|
||||
def list_routes():
|
||||
"""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__':
|
||||
app.run(port=6012)
|
||||
manager.run()
|
||||
|
||||
3
scripts/run_app.sh
Executable file
3
scripts/run_app.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
python application.py runserver
|
||||
Reference in New Issue
Block a user