Skip to main content

Sharpify

Sharpify turns the attribute routing of the Flask framework, into the Conventional routing of Asp.Net

Versions: 0.1.3: Updated README.md

DISCLAIMER:
I don't know whether or not this works in a production environment, since i am only using this for school projects, to make my development easier. I have no experience with blueprints, so i don't know if this package is making scaleablity any better, and there is probably alot of edgecases that is not being handled.

SETUP
After installing the package, you need a folder structure like this:

  • Projectfolder

    • app folder
      • controllers folder Important
      • templates folder Important
    • venv
    • etc..
  • In the controllers folder, you make one .py file per controller. Ex: ExampleController.py

  • Within this pythone file, you make ONE class, with the same name as the file: Ex: class ExampleController():

  • Make sure to import the "View" class, the "httpGet" & "httpPost" decorators (only ones supported right now, but can easily be modified by yourselves)

  • You can then define an action / method to handle a endpoint

@httpGet
def Index(id:int=None):
name = "Peter";
return View(name=name);

this will create the following endpoints:

  • url/Example/Index/
  • url/Example/Index/int:id

It takes the name of the class and strips the "Controller" part, leaving "Example", and then it takes the function name "Index", and then it looks for any parameters and whether or not this parameter is optional. Since python does not have function overloading like C#, you have to handle both the case of the user setting the arguement, and the user leaving it empty.

Returning the correct view / template
return View(**kwargs), when this object is created, it will look at the class name its created in, aswell as the function name. It will then look in your templates folder to find the correct .html file, and return it to the browser.

  • templates
    • example
      • index.html

Any object you pass down to the frontend, can be accessed normally with Jinja2.

Enabling the routing behaviour
In your application init.py, after creating your Flask app object, import and call the "sharpify.use_mvc" function, pass in the app object, and the name of the controller and function you want your webapplication to default to. This will result in "/" pointing to that function.

Using custom attributes for hrefs and form actions
after "use_mvc" is called, you can call "use_htmlAttributes(pathToJsFolder);", this copies a javascript file into your folder, that can be used in any html file. In any anchor element or form element, you can simply write data-controller="Example" data-action="Index" and it will convert it at runtime, to the correct path.

Release files for sharpify 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharpify 0.1.4
File Size Uploaded
sharpify-0.1.4.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharpify 0.1.4
File Interpreter ABI Platform
sharpify-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / sharpify-0.1.4.tar.gz

Download URL sharpify-0.1.4.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf400f1d9549b6fc69c9aaffbf4b9d0dc8f18a2130d86d682041d3a838a04d5a
BLAKE2b-256 checksum
How to use checksums
f9e0d6d21d1b6db61fdc158fa6f785095bf99f4f2476de0841e09f5cc1275104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / sharpify-0.1.4-py3-none-any.whl

Download URL sharpify-0.1.4-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66584f69330d7df18a92cf613073087c6739bac9a0eba59ccccb971cba62dc10
BLAKE2b-256 checksum
How to use checksums
17956043a75e9584eea476687b96eab53c887c0909b1eba012e140857676c8f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page