File tree 8 files changed +70
-23
lines changed
8 files changed +70
-23
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ from flask import Flask
2
+ from my_app .hello .views import hello
3
+
4
+ app = Flask (__name__ )
5
+ app .register_blueprint (hello )
Original file line number Diff line number Diff line change
1
+ MESSAGES = {
2
+ 'default' : 'Hello to the World of Flask!' ,
3
+ }
Original file line number Diff line number Diff line change
1
+ from flask import Blueprint
2
+ from flask import render_template , request
3
+ from my_app .hello .models import MESSAGES
4
+
5
+ hello = Blueprint ('hello' , __name__ )
6
+
7
+
8
+ @hello .route ('/' )
9
+ @hello .route ('/hello' )
10
+ def hello_world ():
11
+ user = request .args .get ('user' , 'Shalabh' )
12
+ return render_template ('index.html' , user = user )
13
+
14
+
15
+ @hello .route ('/show/<key>' )
16
+ def get_message (key ):
17
+ return MESSAGES .get (key ) or "%s not found!" % key
18
+
19
+
20
+ @hello .route ('/add/<key>/<message>' )
21
+ def add_or_update_message (key , message ):
22
+ MESSAGES [key ] = message
23
+ return "%s Added/Updated" % key
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Flask Framework Cookbook</ title >
4
+ </ head >
5
+ < body >
6
+ < h1 > Hello {{ user }}!</ h1 >
7
+ < p > Welcome to the world of Flask!</ p >
8
+ </ body >
9
+ </ html >
Original file line number Diff line number Diff line change
1
+ from my_app import app
2
+ app .run (debug = True )
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: UTF-8 -*-
3
+ import os
4
+ from setuptools import setup
5
+
6
+ setup (
7
+ name = 'my_app' ,
8
+ version = '1.0' ,
9
+ license = 'GNU General Public License v3' ,
10
+ author = 'Shalabh Aggarwal' ,
11
+ author_email = 'contact@shalabhaggarwal.com' ,
12
+ description = 'Hello world application for Flask' ,
13
+ packages = ['my_app' ],
14
+ platforms = 'any' ,
15
+ install_requires = [
16
+ 'flask' ,
17
+ ],
18
+ classifiers = [
19
+ 'Development Status :: 4 - Beta' ,
20
+ 'Environment :: Web Environment' ,
21
+ 'Intended Audience :: Developers' ,
22
+ 'License :: OSI Approved :: GNU General Public License v3' ,
23
+ 'Operating System :: OS Independent' ,
24
+ 'Programming Language :: Python' ,
25
+ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content' ,
26
+ 'Topic :: Software Development :: Libraries :: Python Modules'
27
+ ],
28
+ )
You can’t perform that action at this time.
0 commit comments