{"id":16135376,"url":"https://github.com/marktennyson/flask-express","last_synced_at":"2025-03-18T15:31:28.486Z","repository":{"id":37098926,"uuid":"388180543","full_name":"marktennyson/flask-express","owner":"marktennyson","description":"provide the interactive service like expressJs for flask app.","archived":false,"fork":false,"pushed_at":"2023-06-05T08:59:02.000Z","size":6904,"stargazers_count":5,"open_issues_count":12,"forks_count":1,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-02-28T10:34:21.790Z","etag":null,"topics":["expressjs","flask","flask-application","flask-backend","flask-server","flask-web","python","python3"],"latest_commit_sha":null,"homepage":"http://gh.aniketsarkar.site/flask-express/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marktennyson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-21T16:30:50.000Z","updated_at":"2024-03-08T23:56:44.000Z","dependencies_parsed_at":"2024-10-27T18:21:21.544Z","dependency_job_id":"b0099e8f-3203-4ce7-b208-5941eb340e1f","html_url":"https://github.com/marktennyson/flask-express","commit_stats":{"total_commits":119,"total_committers":3,"mean_commits":"39.666666666666664","dds":0.4789915966386554,"last_synced_commit":"af8b979ac8af74a36703d464a572762a16e46c56"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktennyson%2Fflask-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktennyson%2Fflask-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktennyson%2Fflask-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marktennyson%2Fflask-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marktennyson","download_url":"https://codeload.github.com/marktennyson/flask-express/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243936382,"owners_count":20371504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expressjs","flask","flask-application","flask-backend","flask-server","flask-web","python","python3"],"created_at":"2024-10-09T23:07:32.358Z","updated_at":"2025-03-18T15:31:28.116Z","avatar_url":"https://github.com/marktennyson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flask-express\n\u003cimg src=\"https://raw.githubusercontent.com/marktennyson/flask-express/main/logos/flask-express-logo.png\"\u003e\n\n# Downloads\n[![Downloads](https://pepy.tech/badge/flask-express)](https://pepy.tech/project/flask-express) [![Downloads](https://pepy.tech/badge/flask-express/month)](https://pepy.tech/project/flask-express/month) [![Downloads](https://pepy.tech/badge/flask-express/week)](https://pepy.tech/project/flask-express/week)\n\u003cbr\u003e\n\n#### contributor needed.  \n\nprovide the interactive service like expressJs for the flask app.\n\n\n#### Important Links\n[PYPI link](https://pypi.org/project/flask-express)    \n[Github link](https://github.com/marktennyson/flask-express)    \n[Documentation link](https://marktennyson.github.io/flask-express) \n\n### Basic installation\nUse the package manager [pip](https://pypi.org/project/flask-express/) to install flask-express.\n\n```bash\npython3 -m pip install flask-express\n```\nInstall from source code\n\n```bash\ngit clone https://github.com/marktennyson/flask-express.git \u0026\u0026 cd flask-express/\npython3 setup.py install\n```\n\n### Introduction to Flask-Express\nFlask-Express is here to give you people the feel like ExpressJs while using the Flask app.\nBasically you can use the default Request and Response as two parameters of the view functions.\n\nFlask-Express comes with all the features of Flask with some extra features.\n\nWe are using the `munch` module to provide the attribute-style access very similar to the Javascript.\nI think this is enough for the introdunction, let's play with the examples mentioned below.\n\n### Examples and Usages\n\n##### Basic example: \n\ninbuilt flask_express.FlaskExpress class\n```python\nfrom flask_express import FlaskExpress\n\napp = FlaskExpress(__name__)\n\n@app.get(\"/\")\ndef index(req, res):\n    return res.json(req.header)\n```\n\n##### Now the flask 2.0 support the asynchronus view function. You can implement this with flask-express too.\n\n```python\nfrom flask_express import FlaskExpress\n\napp = FlaskExpress(__name__)\n\n@app.get(\"/\")\nasync def index(req, res):\n    return res.json(req.header)\n```\n\n##### You can use the python typing for a better view of the codes and auto completion.\n\n```python\nfrom flask_express import FlaskExpress\nfrom flask_express.typing import Request, Response\n\napp = FlaskExpress(__name__)\n\n@app.get(\"/\")\ndef index(req:Request, res:Response):\n    return res.json(req.header)\n```\n\n### Basic Documentation\n\nThe official and full documentation for this project is available at: https://marktennyson.github.io/flask-express.\nHere I have tried to provide some of the basic features of this project here.\n\n#### Request class:\nN.B: all of the properties of the Request class will return an instance of Munch.\nThis will provide you the feel of the Javascript object.\n\n##### property - json \nSo if your app is receiving data as json format, you can use `json` property of the request class to access the data.\nIt's internally using the `get_json` method to provide the data.    \n\nFor example:\n\n```python\n@app.post(\"/send-json\")\ndef send_json(req, res):\n    name = req.json.name\n    email = req.json.email\n    return res.json(name=name, email=email)\n```\n\n##### property - query\nThis object provides you the url based parameter. \nIt's internally using the `args` property to provide the data. \n\nFor example:\n\n```python\n@app.get(\"/get-query\")\ndef get_query(req, res):\n    name=req.query.name\n    email = req.query.email\n    return res.send(dict(name=name, email=email))\n```\n\n##### property - body\nThis object provides you the all the parameters from the Form. \nIt's internally using the `form` property to provide the data. \n\nFor example:\n\n```python\n@app.get(\"/get-form-data\")\ndef get_form_data(req, res):\n    name=req.body.name\n    email = req.body.email\n    return res.send(dict(name=name, email=email))\n```\n\n##### property - header\nThis object provides you the all the parameters of the request header. \nIt's internally using the `header` property to provide the data. \n\nFor example:\n\n```python\n@app.get(\"/get-form-data\")\ndef get_form_data(req, res):\n    return res.send(req.header)\n```\n\n#### Response class\n\n##### function - send_status\nThis is used to set the response header status.\n\nfor example:\n```python\n@app.route(\"/set-status\")\ndef set_statuser(req, res):\n    return res.send_status(404).send(\"your requested page is not found.\")\n```\n\n##### function - flash\nTo flash a message at the UI.\n\nfor example:\n```python\n@app.route('/flash')\ndef flasher(req, res):\n    return res.flash(\"this is the flash message\").end()\n```\n\n##### function - send\n It sends the HTTP response.\n\nfor example:\n```python\n@app.route(\"/send\")\ndef sender(req, res):\n    return res.send(\"hello world\")\n    #or\n    return res.send(\"\u003ch1\u003ehello world\u003c/h1\u003e\")\n    #or\n    return res.send_status(404).send(\"not found\")\n```\n\n##### function - json\n To return the json seriliazed response.\n\nfor example:\n```python\n@app.route(\"/json\")\ndef jsoner(req, res):\n    return res.json(name=\"aniket sarkar\")\n    #or\n    return res.json({'name': 'aniket sarkar'})\n    #or\n    return res.json([1,2,3,4])\n```\n\n##### function - end\n To end the current resonse process.\n\nfor example:\n```python\n@app.route(\"/end\")\ndef ender(req, res):\n    return res.end()\n    #or\n    return res.end(404) # to raise a 404 error.\n```\n\n##### function - render\n Renders a html and sends the rendered HTML string to the client.\n\nfor example:\n```python\n@app.route('/render')\ndef renderer(req, res):\n    context=dict(name=\"Aniket Sarkar\", planet=\"Pluto\")\n    return res.render(\"index.html\", context)\n    #or\n    return res.render(\"index.html\", name=\"Aniket Sarkar\", planet=\"Pluto\")\n```\n\n##### function - redirect\n redirect to specified route.\n\nfor example:\n```python\n@app.post(\"/login\")\ndef login(req, res):\n#if login success\nreturn res.redirect(\"/dashboard\")\n```\n\n##### function - get\nGet the header information by the given key.\n\nfor example:\n```python\n@app.route(\"/get\")\ndef getter(req, res):\n    print (res.get(\"Content-Type\"))\n    return res.end()\n```\n\n##### function - set\nSet the header information.\n\nfor example:\n```python\n@app.route(\"/header-seter\")\ndef header_setter(req, res):\n    res.set('Content-Type', 'application/json')\n    #or\n    res.set({'Content-Type':'application/json'})\n    return res.end()\n```\n\n##### function - type\nSets the Content-Type HTTP header to the MIME type as determined by the specified type.\n\nfor example:\n```python\n@app.route(\"/set-mime\")\ndef mimer(req, res):\n    res.type('application/json')\n    #or\n    res.type(\".html\")\n    #or\n    res.type(\"json\")\n```\n\n##### function - attachment\nsend the attachments by using this method.\nThe default attachment folder name is `attachments`.\nYou can always change it by changing the config parameter.\nthe config parameter is `ATTACHMENTS_FOLDER`.\n\nfor example:\n```python\n@app.route('/attachments')\ndef attach(req, res):\n    filename = req.query.filename\n    return res.attachment(file_name)\n```\n\n##### function - send_file\nSend the contents of a file to the client.Its internally using the send_file method from werkzeug.\n\n##### function - clear_cookie\nClear a cookie.  Fails silently if key doesn't exist.\n\n##### function - set_cookie\nSets a cookie.\n\n##### function - make_response\nmake a http response. It's same as `Flask.wrappers.Request`\n\n### Development\n\n#### Beautiful Contributors\n\u003ca href=\"https://github.com/flaskAio/navycut/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=marktennyson/flask-express\" /\u003e\n\u003c/a\u003e\n\n#### Contribution procedure.\n1. Create a new issue on github.\n2. Fork and clone this repository.\n3. Make some changes as required.\n4. Write unit test to showcase its functionality.\n5. Submit a pull request under `main` branch.\n\n#### Run this project on your local machine.\n1. create a virtual environment on the project root directory.\n2. install all the required dependencies from requirements.txt file.\n3. make any changes on you local code.\n4. then install the module on your virtual environment using `python setup.py install` command.\n5. The above command will install the `flask-express` module on your virtual environment.\n6. Now create a separate project inside the example folder and start testing for your code changes.\n7. If you face any difficulties to perform the above steps, then plese contact me at: `aniketsarkar@yahoo.com`.\n\n### Future Roadmap\n1. Middleware support.\n2. Implementation of all the apis of ExpressJs.\n3. Auto Swagger documentation using `flask-restplus` and `flask-pydantic` module.\n\n### License\n\nMIT License\n\nCopyright (c) 2021 Aniket Sarkar(aniketsarkar@yahoo.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarktennyson%2Fflask-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarktennyson%2Fflask-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarktennyson%2Fflask-express/lists"}