时间:2023-09-14 14:24:01 | 来源:网站运营
时间:2023-09-14 14:24:01 来源:网站运营
web有哪些常见框架,你还不知道?:$ pip install django$ django-admin startproject djdemo cd djdemo $ django-admin startapp djapp $ tree -L 3 .├── djapp│ ├── __init__.py│ ├── admin.py│ ├── apps.py│ ├── migrations│ │ └── __init__.py│ ├── models.py│ ├── tests.py│ └── views.py├── djdemo│ ├── __init__.py│ ├── __pycache__│ │ ├── __init__.cpython-37.pyc│ │ └── settings.cpython-37.pyc│ ├── settings.py│ ├── urls.py│ └── wsgi.py└── manage.py
下面我给出我一个项目的Django的目录结构。是django的经典目录结构形式:[django] check compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages makemigrations migrate runserver sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver
$ pip install tg.devtools $ gearbox --helpusage: gearbox [--version] [-v | -q] [--log-file LOG_FILE] [-h] [--debug] [--relative] TurboGears2 Gearbox toolset optional arguments: --version show program's version number and exit -v, --verbose Increase verbosity of output. Can be repeated. -q, --quiet Suppress output except warnings and errors. --log-file LOG_FILE Specify a file to log output. Disabled by default. -h, --help Show this help message and exit. --debug Show tracebacks on errors. --relative Load plugins and applications also from current path. Commands: help print detailed help for another command makepackage Creates a basic python package patch Patches files by replacing, appending or deleting text. quickstart Creates a new TurboGears2 project scaffold Creates a new file from a scaffold template serve Serves a web application that uses a PasteDeploy configuration file setup-app Setup an application, given a config file tgext Creates a tgext.* package
创建项目$ gearbox quickstart tgdemo// 会生成很多文件 .├── MANIFEST.in├── README.txt├── __pycache__│ └── setup.cpython-37.pyc├── development.ini├── migration│ ├── env.py│ ├── script.py.mako│ └── versions│ └── empty.txt├── setup.cfg├── setup.py├── test.ini├── tgdemo│ ├── __init__.py│ ├── config│ │ ├── __init__.py│ │ ├── app_cfg.py│ │ ├── environment.py│ │ └── middleware.py│ ├── controllers│ │ ├── __init__.py│ │ ├── controller.py.template│ │ ├── error.py│ │ ├── root.py│ │ └── secure.py│ ├── i18n│ │ └── ru│ ├── lib│ │ ├── __init__.py│ │ ├── app_globals.py│ │ ├── base.py│ │ └── helpers.py│ ├── model│ │ ├── __init__.py│ │ ├── auth.py│ │ └── model.py.template│ ├── public│ │ ├── css│ │ ├── favicon.ico│ │ ├── fonts│ │ ├── img│ │ └── javascript│ ├── templates│ │ ├── __init__.py│ │ ├── __pycache__│ │ ├── about.xhtml│ │ ├── data.xhtml│ │ ├── environ.xhtml│ │ ├── error.xhtml│ │ ├── index.xhtml│ │ ├── login.xhtml│ │ ├── master.xhtml│ │ └── template.xhtml.template│ ├── tests│ │ ├── __init__.py│ │ ├── functional│ │ └── models│ └── websetup│ ├── __init__.py│ ├── bootstrap.py│ └── schema.py└── tgdemo.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── entry_points.txt ├── not-zip-safe ├── requires.txt └── top_level.txt 22 directories, 48 files
上面 是按python包的方式生成的代码形式,方便打包分发。 from wsgiref.simple_server import make_server from tg import expose, TGController, AppConfig class RootController(TGController): @expose() def index(self): return "<h1>Hello World</h1>" config = AppConfig(minimal=True, root_controller=RootController()) print "Serving on port 8080..." httpd = make_server('', 8080, config.make_wsgi_app()) httpd.serve_forever()
project/ README LICENSE VERSION > this web2py version web2py.py > the startup script anyserver.py > to run with third party servers ... > other handlers and example files gluon/ > the core libraries packages/ > web2py submodules dal/ contrib/ > third party libraries tests/ > unittests applications/ > are the apps admin/ > web based IDE ... examples/ > examples, docs, links ... welcome/ > the scaffolding app (they all copy it) ABOUT LICENSE models/ views/ controllers/ sessions/ errors/ cache/ static/ uploads/ modules/ cron/ tests/ ... > your own apps examples/ > example config files, mv .. and customize extras/ > other files which are required for building web2py scripts/ > utility and installation scripts handlers/ wsgihandler.py > handler to connect to WSGI ... > handlers for Fast-CGI, SCGI, Gevent, etc site-packages/ > additional optional modules logs/ > log files will go in there deposit/ > a place where web2py stores apps temporarily
from flask import Flask app = Flask(__name__) @app.route('/')def hello(): return 'Hello, World!'
Bottlefrom bottle import route, run, template @route('/hello/<name>')def index(name): return template('<b>Hello {{name}}</b>!', name=name) run(host='localhost', port=8080)
多框架关键词: