Giter Site home page Giter Site logo

Comments (7)

prashnts avatar prashnts commented on May 21, 2024 1

In a recent project, I'd needed needed both Auto Reload and Static file serving capabilities.
Using hug, this is the solution I came up with.

  • Use static for a WSGI compatible static file handling.
  • Write the API as usual using hug.
  • Use pecan_mount to mount __hug__ and static to a single WSGI point.
  • Run this with gunicorn's Auto Reload turned on.

And there, a quick and easy solution. 😆

Here's a snippet in case anybody's interested.

import hug
import pecan_mount
import static

@hug.get('/', versions=1)
def get_root():
  return True

# Mount Hug at `/api` and static files at '/'
pecan_mount.tree.graft(__hug_wsgi__, '/api')
pecan_mount.tree.graft(static.Cling("/path/to/static/root"), '/')

app = pecan_mount.tree

Running with gunicorn: $ gunicorn module:app --reload

I'm looking forward to version 3, though!

from hug.

timothycrosley avatar timothycrosley commented on May 21, 2024 1

Closing this as this feature is now completed in development and ready for the next release.

Thanks!

~Timothy

from hug.

arthurk avatar arthurk commented on May 21, 2024

Here's a recent discussion about auto-reloading on the django-developers mailing list: https://groups.google.com/forum/#!topic/django-developers/voXNIDdDcpU. It has a few good ideas on how to improve Django's auto-reloading, but it might be useful for Hug too

from hug.

timothycrosley avatar timothycrosley commented on May 21, 2024

@arthurk, I think that's super helpful as we think about how to implement hug's solution. Thanks for finding and sharing!

~Timothy

from hug.

sloria avatar sloria commented on May 21, 2024

There is a WIP PR for a debug server in falcon: falconry/falcon#517

from hug.

timothycrosley avatar timothycrosley commented on May 21, 2024

@sloria thanks for linking! Hopefully will be able to get this in for the 2.0.0 release :)

from hug.

stavxyz avatar stavxyz commented on May 21, 2024

FWIW, here's a link to the relevant code in the latest release of bottle:

https://github.com/bottlepy/bottle/blob/0.12.9/bottle.py#L3131-L3169
https://github.com/bottlepy/bottle/blob/0.12.9/bottle.py#L3109-L3115

from hug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.