{"id":19721997,"url":"https://github.com/datajoint/djwebtools","last_synced_at":"2025-04-29T22:30:33.498Z","repository":{"id":148762850,"uuid":"39469068","full_name":"datajoint/djwebtools","owner":"datajoint","description":"Flask tools to write small web applications for datajoint","archived":true,"fork":false,"pushed_at":"2015-12-09T21:53:50.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-02-28T00:29:29.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datajoint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-21T20:46:21.000Z","updated_at":"2023-04-12T18:05:22.000Z","dependencies_parsed_at":"2023-04-15T13:21:31.746Z","dependency_job_id":null,"html_url":"https://github.com/datajoint/djwebtools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fdjwebtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fdjwebtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fdjwebtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fdjwebtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datajoint","download_url":"https://codeload.github.com/datajoint/djwebtools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251592899,"owners_count":21614441,"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":[],"created_at":"2024-11-11T23:16:10.139Z","updated_at":"2025-04-29T22:30:33.206Z","avatar_url":"https://github.com/datajoint.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# djwebtools\nFlask tools to write small web applications for datajoint.\n\n**This is an alpha version**: Use with caution.\n\n## Installation\n\nClone the repository and put into your shell\n\n```sudo pip3 install -e djwebtools```\n\nThe ```-e``` will install it locally, you want to install it into the system.\n\n## Minimal example\n\nYou need a running [datajoint](http://datajoint.github.io/) installation with a database server.\n\nAssume you have a datajoint `Subject` in the file `myschema.py` that looks like this:\n\n```python\n\nimport datajoint as dj\nschema = dj.schema('mydbname', locals())\n\n\n@schema\nclass Subject(dj.Manual):\n    definition = \"\"\"  # Basic information about animal subjects used in experiments\n    subject_id   :int  #  unique subject id\n    ---\n    real_id            :varchar(40)  # real-world name. Omit if the same as subject_id\n    species = \"mouse\"  :enum('mouse', 'monkey', 'human')\n    date_of_birth      :date\n    subject_notes      :varchar(4000)\n    \"\"\"\n\n    contents = [\n        [1551, '1551', 'mouse', '2015-04-01', 'genetically engineered super mouse'],\n        [10, 'Curious George', 'monkey', '2008-06-30', ''],\n        [1552, '1552', 'mouse', '2015-06-15', ''],\n        [1553, '1553', 'mouse', '2016-07-01', '']]\n\n    def prepare(self):\n        self.insert(self.contents, ignore_errors=True)\n\n```\n\nThe next step is to create a [Flask](http://flask.pocoo.org/) application with the following directory structure.\n\n```\n├── dj_local_conf.json\n├── myserver.py\n├── static\n│   └── style.css\n└── templates\n    └── base.html\n\n```\n\nThe file `dj_local_conf.json` contains your database information. See the documentation of [datajoint](http://datajoint.github.io/).\n\nThe file `base.html` could look like this\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead lang=\"en\"\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle\u003eSubject Administration System\u003c/title\u003e\n    \u003clink rel=stylesheet type=text/css href=\"{{ url_for('static', filename='style.css') }}\"\u003e\n    {% block datajointhead%} {% endblock %}\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cdiv class=\"main\"\u003e\n    {% block body%}\n\n    {% endblock %}\n\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nNotice the `datajointhead` in the heading. `djwebtools` will place the custom `.css` file there. If you don't want that,\nremove it. The file has to be named `base.html` since, the templates in `djwebtools` will extend it.\n\nThe file `myserver.py` could look like this\n\n```python\nfrom flask import Flask\nimport djwebtools as djw\n\napp = Flask(__name__)\napp.secret_key = # place a flask secret key here\napp.register_blueprint(djw.djpage, url_prefix='/dj')\n\n\n\nimport atlab_commons\nfrom myschema import Subject\n\ndjw.register(subject=Subject(), for_form=True)\n\nif __name__ == '__main__':\n    app.run(debug=True)\n\n```\n\nThis file registeres the flask blueprint from `djwebtools` with your flask application. If you run it via:\n\n```python3 myserver.py```\n\n`djwebtools` will provide the following URLs\n\n- http://127.0.0.1:5000/dj/display/subject\n- http://127.0.0.1:5000/dj/enter/subject\n\nIt also provides a URL for editing, but that is better accessed from the display URL, since it needs a few GET parameters\nto fetch the correct entry from the database.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajoint%2Fdjwebtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatajoint%2Fdjwebtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajoint%2Fdjwebtools/lists"}