Written and hosted by Andrew Chilton (@andychilton) since 2009.
No ads in .
Credits: Thanks to Cristian Tomatis for contributing this example.
import requests url = 'http://localhost:80/raw' data = {'input': open('style.css', 'rb').read()} response = requests.post(url, data=data) print response.text
Credits: Thanks to Noam Yorav-Raphael for contributing this example.
>>> import requests >>> requests.post('http://localhost:80/raw', data=dict(input='p { color : red; }')).text 'p{color:red}'
Credits: Thanks to Kyle S. for contributing this to the site.
# -*- coding: utf-8 -*- import sys import requests try: css_file = sys.argv[1] except: print("Missing input file") sys.exit() # Grab the file contents with open(css_file, 'r') as c: css = c.read() # Pack it, ship it payload = {'input': css} url = 'http://localhost:80/raw' print("Requesting mini-me of {}. . .".format(c.name)) r = requests.post(url, payload) # Write out minified version minified = css_file.rstrip('.css')+'.min.css' with open(minified, 'w') as m: m.write(r.text) print("Minification complete. See {}".format(m.name))
Many people have sent language examples over the years, but we want more! We'd love to add more examples in your favourite programming language, so please send them our way. Email andychilton at that gmail place in the sky, tweet me @andychilton, or open an issue or PR on webdev-sh/cssminfier.com.
Click on the language of your choice to see an example: