Is it possible to change the port number on HUG for python? I have the following sample of what I'm trying to do. The API defaults to port 8000 but I want to be able to set it manually.
@hug.post()
def receive_json(request):
request=str(request)
print("Hello! Glad you're here!")
print(request)
process=os.system("echo "+'"'+request+'"')
add at the end of your app.py
(or whatever it's name is) file:
hug.API(__name__).http.serve(port=8005)
for serving on port 8005
If you are using the hug
command line script to start your app, the -p / --port
option will get you there, as in hug --port 5000 -f app.py
:
$ hug --help
usage: hug [-h] [-v] [-f FILE] [-m MODULE] [-p PORT] [-n] [-ma] [-i INTERVAL]
[-c COMMAND]
Hug API Development Server
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-f FILE, --file FILE file
-m MODULE, --module MODULE
module
-p PORT, --port PORT A Whole number
-n, --no_404_documentation
Providing any value will set this to true
-ma, --manual_reload Providing any value will set this to true
-i INTERVAL, --interval INTERVAL
A Whole number
-c COMMAND, --command COMMAND
command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With