DISCLAIMER
This Library currently supports only static routing. The dynamic routing will be added in the future release
Usage
Basic Usage
- Create a folder with a name
homein the root dir of your project. You can renamehomefolder to custom name inrouter.config.jsonwhich should be created in the root dir. - The folder
homeis gonna be workspace directory of your all api routes. - e.g. for path
home/api.pythe route willhttp://localhost:<PORT>/api - create and open
app.pyin the root dir of your project.
app.py
# app.py
from flask import Flask
from flask.cors import CORS
from flask_file_router.router import Router
app = Flask(__name__)
CORS(app)
app.config['CORS_HEADERS'] = "Content-Type"
Router(app).run()
if __name__=="main":
app.run(host="0.0.0.0", port=4000, debug=True)
home/api.py
# home/api.py
from flask import request
methods = ["POST"] # put GET for GET request
def main(): # This function have to be named as main. This gets triggered Whenever it hits api
body = request['json']
return ""
Configurations
{
"root_dir": "./home", // name of the workspace home dir
"default_index": "__main__.py", // This is the default index route for the given folder
"ext_exclude_list": ["pyc"], // file with this extension will be ignored
"ext_include_list": ["py"] //file with this extension will be considered for api router and rest are ignored
}
Note:
ext_exclude_listandext_include_listare exclusive porps. e.g. ifext_include_listprovidedext_exclude_listwill be ignored.
File Structure examples
Consider the following file system structure
home/v1/api.pyhome/v1/__main__.pyhome/v1/get_user.py
The api router for the above file structure will be as follows
https://localhost:4000/v1/apihttps://localhost:4000/v1https://localhost:4000/v1/get_user
Release files for flask-file-router 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_file_router-0.0.5.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_file_router-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / flask_file_router-0.0.5.tar.gz
| Download URL | flask_file_router-0.0.5.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c26e96cc72296ea914ba44104f65b997ef6def1fd30278719554e474cff891c6
|
|
BLAKE2b-256 checksum How to use checksums |
dd80ff4f62854f079974b45a6752f3fa21b00aa8a72d0445dc8012dcc23b7b59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.5
|
Release files / flask_file_router-0.0.5-py3-none-any.whl
| Download URL | flask_file_router-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d46b32e4ae48760aaf5fa583c1af568c374e38c19eaba55604710e6d1213e402
|
|
BLAKE2b-256 checksum How to use checksums |
40d71cb0577cfdd80f6a84e34fc8db6c7e0b03c11c831e0c2390fd0df3ce319b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.5
|