flask-node
v0.5.2
Published
similar to python Flask web-framework
Downloads
7
Readme
Flask-node
Similar to python Flask web-framework
Install
You can use npm
or yarn
install the Flask-node
npm install flask-node --save
// or
yarn add flask-node --save
Usage
/** Typescript app.ts */
import { Flask, Router, Request, Response } from 'flask-node';
const app = new Flask(__dirname);
const router = new Router();
function indexHandle(req: Request, res: Response) {
res.end('Hello world');
}
router.add('/', indexHandle);
app.run({ port: 5051 });
or
/** Javascript app.js */
const { Flask, Router } = require('flask-node');
const app = new Flask(__dirname);
const router = new Router();
function indexHandle(req, res) {
res.end('Hello world');
}
router.add('/', indexHandle);
app.run({ port: 5051 });
// run app
node app.js // ==> Server is run on http://localhost:5051
// use curl test app.js
curl http://localhost:5051 // ==> Hello world
Features
- Support dynamic routing
- Support HTML template engine (use Swig)
- Natice support HTTP body parse (use formidable)
Documentation
Test
run npm test
Contribution
- fork this repo
- run
npm install
install dependencies - write your code and run
git cz
commit your code - run
npm test
and ensure that all tests pass - pull request , tks
License
MIT © Lleohao